stackhpc.grafana-conf
Configure Grafana Datasources and Dashboards
This is a simple role for loading dashboards and datasources into Grafana. The main rule is that if there is already a dashboard or datasource with the same name, it will not be updated.
Currently, this works at the organization level.
Usage
You can find an example of how to use this role in the example/
folder.
Requirements: Ansible version 2.2 or higher. If your Linux distribution does not provide it, you can run Ansible in a virtual environment (venv):
- Create a venv:
$ virtualenv ansible
- Activate the venv:
$ source ansible/bin/activate
- Update pip (optional):
$ pip install -U pip
- Install Ansible:
$ pip install ansible
Creating Dashboards
To avoid Grafana removing datasource names, dashboards should be downloaded using the API. You can do this with curl or through your web browser. Here’s how to do it using a browser:
- Switch to the organization in Grafana that has the dashboard you want to save.
- Then, in the same browser, access the dashboard via the API using the following URL:
http://10.1.2.3:3000/api/dashboards/db/tenant-logs
This will return the dashboard as a JSON string. To ensure the dashboard loads correctly, you need to set the dashboard ID to null. For example:
<snip>
"dashboard":{
"annotations":{"list":[]},
"editable":true,
"gnetId":null,
"hideControls":false,
"id":null, <-- Must be null
"links":[],
"rows": </snip>
Role to configure Grafana dashboards and datasources
ansible-galaxy install stackhpc.grafana-conf