canonical / grafana-k8s-operator

https://charmhub.io/grafana-k8s
Apache License 2.0
6 stars 22 forks source link

Grafana Operator for k8s

CharmHub Badge Release Discourse Status

Charmed Grafana (grafana-k8s) is a charm for Grafana.

This charm imposes configurable resource limits on the workload, can be readily integrated with various data sources such as prometheus or loki, automatically generates topology dropdowns, and comes with built-in alert rules for self-monitoring.

It is an essential part of the COS Lite bundle.

Usage

The Grafana Operator may be deployed on a Kubernetes Juju model using the command line via:

juju deploy grafana-k8s

At install time, Grafana does not contain any data sources or dashboards, but Prometheus is commonly used, and is deployable with Juju. The Grafana Operator may also accept additional datasources over Juju relations with charms which support the grafana-datasource interface, such as Loki log visualization.

For example:

juju deploy prometheus-k8s
juju relate prometheus-k8s grafana-k8s

The Grafana Operator includes a Charm library which may be used by other Charms to easily provide datasources. Currently, Prometheus and Loki are tested, with datasource integration built into those charms, but any Grafana datasource which does not require the addition of a plugin should be supported. See the documentation for the charms.grafana_k8s.v0.grafana_source to learn more.

Web Interface

The Grafana dashboard may be accessed on port 3000 on the IP address of the Grafana unit. This unit and its IP address can be retrieved using the juju status command.

The default password is randomized at first install, and can be retrieved with:

juju run grafana-k8s/0 get-admin-password # juju >=3
###
JUJU_FEATURES=actions-v2 juju run grafana-k8s/0 get-admin-password # juju 2

View the dashboard in a browser:

  1. juju status to check the IP of the running Grafana application
  2. Navigate to http://IP_ADDRESS:3000
  3. Log in with the username admin, and the password you got from the get-admin-password action.

To manually set the admin password, see the official docs.

Additionally, Grafana can be accessed via the Kubernetes service matching the Juju application name in the namespace matching the Juju model's name.

Integration with other charms/adding external dashboards

The grafana-k8s charm does not support directly relating to Reactive charms over the dashboards interface, and it does not support adding dashboards via an action similar to the Reactive Grafana Charm as a design goal. For scenarios where Reactive charms which provide dashboards should be integrated, the COS Proxy charm can be deployed in a Reactive model, and related to grafana-k8s to provide a migration path.

Dashboards which are not bundled as part of a charm can be added to grafana-k8s with the COS Config Charm, which can keep a git repository holding your infrastructure-as-code configuration. See the COS Config documentation for more information.

To Bundle Dashboards As Part of Your Charm

See the documentation for the charm.grafana_k8s.v0.grafana_dashboard library. Generally, this only requires adding a grafana-dashboard interface to your charm and putting the dashboard templates into a configurable path.

High Availability Grafana

This charm is written to support a high-availability Grafana cluster, but a database relation is required (MySQL or Postgresql).

If HA is not required, there is no need to add a database relation.

NOTE: HA should not be considered for production use.

Relations

grafana_datasource - An input for grafana-k8s datasources
grafana_dashboard - an input for LZMA compressed base64 encoded dashboard data

OCI Images

This charm is periodically updated to the latest version of the ubuntu/grafana image.

Contributing

See the Juju SDK docs for guidelines on configuring a development environment and best practices for authoring.