Grafana

Channel Version Revision Published Runs on
latest/stable 78bec2e 59 17 Oct 2022
Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04
latest/candidate 23.01 65 17 Jan 2023
Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04
latest/edge 23.01 65 17 Jan 2023
Ubuntu 20.04 Ubuntu 18.04
juju deploy grafana
Show information

Platform:

Ubuntu
20.04 18.04 16.04

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.

LDAP auth

Grafana can be deployed to utilize LDAP as an authentication mechanism. To enable LDAP authentication, all ldap_* config options (except ldap_config_flags) must be set.

Additional config settings as defined in the upstream LDAP Authentication documentation may be set using the ldap_config_flags option.

Group mappings for permissions should be defined with the following:

ldap_config_flags: "{
    group_mapping_admin: 'cn=grafanaadmins,dc=test,dc=com',
    group_mapping_editor: 'cn=grafanaeditors,dc=test,dc=com',
    group_mapping_viewer: 'cn=grafanaviewers,dc=test,dc=com',
}"

Server attributes should be defined as attribute_<attribute>. Example:

ldap_config_flags: "{
    "attribute_member_of: memberOf,"
    "attribute_email: email,"
    "attribute_name: givenname,"
    "attribute_surname: sn,"
    "attribute_username: cn,"
}"

Development

After modifying code, you must assemble the charm:

charmcraft pack

Contributing

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

Charm code can be found at: https://code.launchpad.net/charm-grafana

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