/interface-grafana-dashboard

Interface layer for importing dashboards into Grafana

Primary LanguagePythonApache License 2.0Apache-2.0

Interface grafana-dashboard

This is a Juju interface layer that enables a charm which provides dashboards to be imported into Grafana.

You can download existing Grafana Dashboards or use the Grafana Dashboard Reference to create your own.

Example Usage

First, you must define the relation endpoint in your charm's metadata.yaml:

provides:
  grafana:
    interface: grafana-dashboard

Next, you must ensure the interface layer is included in your layer.yaml:

includes:
  - interface:grafana-dashboard

Then, in your reactive code, add the following, modifying the dashboard data as your charm needs:

import json
from charms.reactive import endpoint_from_flag


@when('endpoint.grafana.joined')
def register_grafana_dashboards():
    grafana = endpoint_from_flag('endpoint.grafana.joined')
    for dashboard_file in Path('files/grafana').glob('*.json'):
        dashboard = json.loads(dashboard_file.read_text())
        grafana.register_dashboard(name=dashboard_file.stem,
                                   dashboard=dashboard)

Reference

Contact Information

Maintainer: Cory Johns <Cory.Johns@canonical.com>