Grafana
- Canonical Observability
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 117 | 10 Sep 2024 | |
latest/candidate | 117 | 28 Jun 2024 | |
latest/beta | 117 | 21 Jun 2024 | |
latest/edge | 121 | 18 Oct 2024 | |
1.0/stable | 93 | 12 Dec 2023 | |
1.0/candidate | 93 | 22 Nov 2023 | |
1.0/beta | 93 | 22 Nov 2023 | |
1.0/edge | 93 | 22 Nov 2023 |
juju deploy grafana-k8s --channel candidate
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
Integrate a datasource with Grafana
Grafana offers native integration with a number of datasources. If you are charming an application that is a supported grafana datasource, you can integrate with the grafana-k8s
charm to automatically provision the datasource in grafana.
For an example of charms that already do that, see loki
and prometheus
.
Add an integration endpoint to metadata.yaml
Datasource spec is communicated over relation data, where the Grafana charm is the requirer and the datasource server is the provider.
For consistency accross the ecosystem, it is encouraged to name the relation grafana-source
.
Edit your charm’s metadata.yaml
to add, under provides
, the following:
provides:
# any other providers your charm supports
grafana-source:
interface: grafana_source
Fetch the grafana_source charm library
The Grafana charm will provision a datasource per grafana_source
relation, which is managed by the grafana_source
library.
charmcraft fetch-lib charms.grafana_k8s.v0.grafana_source
The library offers a GrafanaSourceProvider
object, which provides sensible defaults and a simple API that you can use to configure the datasource.
Use GrafanaSourceProvider
If you are adding a prometheus
datasource:
from charms.grafana_k8s.v0.grafana_source import GrafanaSourceProvider
class FooCharm:
def __init__(self, *args):
super().__init__(*args, **kwargs)
...
self.grafana_source_provider = GrafanaSourceProvider(
self, source_type="prometheus"
)
...
This will ensure that each unit of Foo
is added as a datasource in the Grafana configuration once a
relation is established.
Configure GrafanaSourceProvider
Certain datasources require additional configuration. That can be passed to GrafanaSourceProvider
as constructor arguments.
source_port
: the port at which the datasource server is listening. Defaults to9090
.source_url
: fully resolvable url at which the datasource server can be reached (useful for example if you are sitting behind an ingress). If provided,source_port
will be ignored. If not provided, the library will use the fqdn. Should be reachable from the grafana pod.relation_name
: name of the binding. Defaults tografana-source
.refresh_event
: event or list of events on which the library will refresh the source url. Useful if the charm’s address is changed as a consequence of a restart (pod churn on k8s).