Grafana

juju deploy grafana
Show information
You will need Juju 2.9 to be able to run this command. Learn how to upgrade to Juju 2.9.
Channel Version Revision Published Base
latest/stable 49 49 26 Jul 2021
20.04 18.04 16.04
latest/candidate 49 49 26 Jul 2021
20.04 18.04 16.04

Platform:

20.04 18.04 16.04

About

Graph and Dashboard builder Read more


Relevant links


Discuss this charm

Share your thoughts on this charm with the community on discourse.

Join the discussion

Overview

This charm provides the latest stable version of Grafana.

Usage

juju deploy grafana
juju add-relation prometheus:grafana-source grafana:grafana-source

Above will automatically configure prometheus as grafana datasource

If admin password is not set using configuration option it is autogenerated.

To retrieve autogenerated password run:

juju run-action --wait grafana/0 get-admin-password

To have dashboards delivered by charm relations, e.g. from Telegraf, add an extra relation as follows.

juju add-relation telegraf:dashboards grafana:dashboards

Actions

This charm supports importing dashboards, simply run:

juju run-action --wait grafana/0 import-dashboard dashboard="$(base64 mydashboard.json)"

where mydashboard.json is a json file:

{ "dashboard": { exported-json-dashboard }, "overwrite": true }

If you don't want to overwrite the dashboard, set overwrite to false.

There is also an action to create an API key, run:

juju run-action --wait grafana/0 create-api-key keyname=<name> keyrole=<role>

where the keyrole is one of Viewer, Editor, Read Only Editor or Admin.

User Management Actions

Currently user management is only implemented to manipulate users in the default organisation.

You can retrieve the admin password, via:

juju run-action --wait grafana/0 get-admin-password

You can create a user:

juju run-action -w grafana/0 create-user name="John Citizen" \
   email="john@example.com" login="john" password="redacted" \
   role="Viewer"

where the role is one of Viewer, Editor, Read Only Editor or Admin. This will create the user in the default organisation.

To reset a user's password:

juju run-action --wait grafana/0 set-user-password \
     login=john new-password=citizen2

This again assumes the user is in the default organisation, if it isn't it won't find the user.

If you need to change the user's role, run:

juju run-action --wait grafana/0 change-user-role login="john" \
        new-role="Admin"

To delete a user, you simply run:

juju run-action --wait grafana/0 delete-user login=john
Upgrade action

To perform an upgrade after changing snap_channel an upgrade action must be run:

juju run-action --wait grafana/0 do-upgrade

Auth proxy

If deployed behind a reverse proxy, you can configure Grafana to let it handle authentication by enabled auth-proxy.

juju config grafana auth-proxy=true

Check grafana documentation on how to configure apache as the reverse proxy.

Users will be created/signup automatically with "Viewer" permissions. To change the default permissions of a user, use the change-user-role action passing the openID identifier or the email if the user updated it as the "login":

juju run-action --wait grafana/0 change-user-role \
     login="user@company.com" new-role="Admin"

If not all URL paths are behind the reverse proxy auth, and anonymous=true is set, those paths will be accessible (view only) to non-authenticated users.

Development

After modifying code, you must assemble the charm:

charm build

Known Issues

  • LP#1901044: In stable/20.10, When deploying grafana, prometheus and prometheus-ceph-exporter for the first time, Grafana will check if Ceph related metrics exist in Prometheus. If such metrics don't exist at the time of adding the relation, the Ceph dashboards won't be imported. In order to fix this problem, the grafana:grafana-source relation should be recycled (juju remove-relation grafana:grafana-source prometheus, followed by juju add-relation grafana:grafana-source prometheus).

  • LP#1901041: Xenial functional tests fail when changing Grafana's port via Juju config.

Contact Information

Author: Alvaro Uria alvaro.uria@canonical.com, Jacek Nykis jacek.nykis@canonical.com

Report bugs at: https://bugs.launchpad.net/charm-grafana

Location:

Release information

Release 20.08:

  • Note that in cs:grafana-36, the Grafana charm shipped a default dashboard for Telegraf. This is removed as of release 20.08, relying instead on the dashboard delivered by the grafana:dashboard relation endpoint.
  • Dashboard titles are now tagged with "[juju-{provider}]"
  • Folks upgrading to the current release will potentially need to add the relation for dashboard import:

    juju add-relation grafana:dashboards $application:dashboards