grafana #0

Supports: kubernetes

Deploy this charm on Kubernetes with the CLI. Find out how by reading the docs.

Description

Grafana provides dashboards for monitoring data and this charm is written to allow for HA on Kubernetes and can take multiple data sources (for example, Prometheus).


Grafana Charm

Description

This is the Grafana charm for Kubernetes using the Operator Framework. It is under active development and should not yet be considered for production use.

Usage

Initial setup (ensure microk8s is a clean slate with microk8s.reset or a fresh install with snap install microk8s --classic:

microk8s.enable dns storage registry dashboard
juju bootstrap microk8s mk8s
juju add-model lma
juju create-storage-pool operator-storage kubernetes storage-class=microk8s-hostpath

Deploy Grafana on its own:

git clone git@github.com:canonical/grafana-operator.git
cd grafana-operator
charmcraft build
juju deploy ./grafana.charm

View the dashboard in a browser: 1. juju status to check the IP of the of the running Grafana application 2. Navigate to http://IP_ADDRESS:3000 3. Log in with the default credentials username=admin, password=admin.

Add Prometheus as a datasource:

git clone git@github.com:canonical/prometheus-operator.git
cd prometheus-operator
charmcraft build
juju deploy ./prometheus.charm
juju add-relation grafana prometheus
watch -c juju status --color  # wait for things to settle down

Once the deployed charm and relation settles, you should be able to see Prometheus data propagating to the Grafana dashboard.

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: Consider HA to be in an alpha release.

...

Developing

Create and activate a virtualenv, and install the development requirements,

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt

Testing

Just run run_tests:

./run_tests

Configuration

advertised_port
(int) The port grafana will be listening on
3000
basic_auth_password
(string) Basic authorization password for Grafana
admin
basic_auth_username
(string) Basic authorization username for Grafana
admin
config_ini_mount_path
(string) The Grafana-defined location of the config.ini file.
/etc/grafana
datasource_mount_path
(string) The Grafana-defined location of the datasource provisioning config file.
/etc/grafana/provisioning/datasources
grafana_image_password
(string) The password associated with grafana_image_username for accessing the registry specified in grafana_image_path.
grafana_image_path
(string) The location of the image to use, e.g. "registry.example.com/grafana:v1". This setting is required.
grafana/grafana:latest
grafana_image_username
(string) The username for accessing the registry specified in grafana_image_path.
grafana_log_level
(string) Logging level for Grafana. Options are “debug”, “info”, “warn”, “error”, and “critical”.
info
grafana_log_mode
(string) The mode of Grafana logs. Possible values are 'console', 'file', and 'syslog'.
file
provisioning_path
(string) The location of all the provisioning files used by Grafana.
/etc/grafana/provisioning