community.grafana.grafana_dashboard module – Manage Grafana dashboards
Note
This module is part of the community.grafana collection (version 1.9.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.grafana
.
To use it in a playbook, specify: community.grafana.grafana_dashboard
.
New in community.grafana 1.0.0
Synopsis
Create, update, delete, export Grafana dashboards via API.
Parameters
Parameter |
Comments |
---|---|
PEM formatted certificate chain file to be used for SSL client authentication. This file can also include the key as well, and if the key is included, client_key is not required |
|
PEM formatted file that contains your private key to be used for SSL client authentication. If client_cert contains both the certificate and key, this option is not required. |
|
Set a commit message for the version history. Only used when
|
|
Public Grafana.com dashboard id to import |
|
Revision of the public grafana dashboard to import Default: |
|
The Grafana folder where this dashboard will be imported to. Default: |
|
The Grafana API key. If set, |
|
The Grafana organization ID where the dashboard will be imported / exported / deleted. Not used when grafana_api_key is set, because the grafana_api_key only belongs to one organization. Mutually exclusive with Default: |
|
The Grafana organization name where the dashboard will be imported / exported / deleted. Not used when grafana_api_key is set, because the grafana_api_key only belongs to one organization. Mutually exclusive with |
|
Override existing dashboard when state is present. Choices:
|
|
The path to the json file containing the Grafana dashboard to import or export. A http URL is also accepted (since 2.10). Required if |
|
Deprecated since Grafana 5. Use grafana dashboard uid instead. slug of the dashboard. It’s the friendly url name of the dashboard. When If you want to import a json dashboard exported directly from the interface (not from the api), you have to specify the slug parameter because there is no meta section in the exported json. |
|
State of the dashboard. Choices:
|
|
uid of the dashboard to export when |
|
The Grafana URL. |
|
The Grafana password for API authentication. Default: |
|
The Grafana user for API authentication. Default: |
|
If Choices:
|
|
If This should only set to Choices:
|
Examples
- name: Import Grafana dashboard foo
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
state: present
commit_message: Updated by ansible
overwrite: true
path: /path/to/dashboards/foo.json
- name: Import Grafana dashboard Zabbix
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
folder: zabbix
dashboard_id: 6098
dashboard_revision: 1
- name: Import Grafana dashboard zabbix
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
folder: public
dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
- name: Export dashboard
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_user: "admin"
grafana_password: "{{ grafana_password }}"
org_id: 1
state: export
uid: "000000653"
path: "/path/to/dashboards/000000653.json"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
uid or slug of the created / deleted / exported dashboard. Returned: success Sample: |