ansible.builtin.grafana_dashboard (v2.6.20) — module

Manage Grafana dashboards

| "added in version" 2.5 of ansible.builtin"

Authors: Thierry Sallé (@tsalle)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.6.20

Description

Create, update, delete, export Grafana dashboards via API.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Import Grafana dashboard foo
  grafana_dashboard:
    grafana_url: http://grafana.company.com
    grafana_api_key: XXXXXXXXXXXX
    state: present
    message: Updated by ansible
    overwrite: yes
    path: /path/to/dashboards/foo.json
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Export dashboard
  grafana_dashboard:
    grafana_url: http://grafana.company.com
    grafana_api_key: XXXXXXXXXXXX
    state: export
    slug: foo
    path: /path/to/dashboards/foo.json

Inputs

    
path:
    description:
    - The path to the json file containing the Grafana dashboard to import or export.

slug:
    description:
    - slug of the dashboard. It's the friendly url name of the dashboard.
    - When C(state) is C(present), this parameter can override the slug in the meta section
      of the json file.
    - 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:
    choices:
    - absent
    - export
    - present
    default: present
    description:
    - State of the dashboard.
    required: true

org_id:
    default: 1
    description:
    - The Grafana Organisation ID where the dashboard will be imported / exported.
    - Not used when I(grafana_api_key) is set, because the grafana_api_key only belongs
      to one organisation..

message:
    description:
    - Set a commit message for the version history.
    - Only used when C(state) is C(present).

overwrite:
    default: 'no'
    description:
    - Override existing dashboard when state is present.
    type: bool

grafana_url:
    description:
    - The Grafana URL.
    required: true

grafana_user:
    default: admin
    description:
    - The Grafana API user.

validate_certs:
    default: 'yes'
    description:
    - If C(no), SSL certificates will not be validated.
    - This should only be used on personally controlled sites using self-signed certificates.
    type: bool

grafana_api_key:
    description:
    - The Grafana API key.
    - If set, I(grafana_user) and I(grafana_password) will be ignored.

grafana_password:
    default: admin
    description:
    - The Grafana API password.

Outputs

slug:
  description: slug of the created / deleted / exported dashboard.
  returned: success
  sample: foo
  type: string