community.grafana icon indicating copy to clipboard operation
community.grafana copied to clipboard

Create Grafana 'add annotation' module

Open aorfanos opened this issue 4 years ago • 2 comments

SUMMARY

Add a single annotation to Grafana via Ansible, with dynamic variables (e.g. endpoint, dashboard_id's).

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

community.grafana.add_grafana_annotation

ADDITIONAL INFORMATION

I wanted to utilise Grafana annotations for my Ansible deployments, but the callback plugin seemed too limited for my use-case (different Grafana endpoints - various projects/environments and single Ansible repo, different dashboards to be updated by each role etc, which I believe is a common setup for many people).

An 'add annotation' module is more useful for that kind of operation, because it can utilise group_vars or defaults to achieve the desired result.

I have created a sample module at my GitHub, let me know if it needs anything else to be included in community.grafana.

- name: Create a Grafana annotation
  add_grafana_annotation:
    grafana_api_url: "https://grafana.myproject.com"
    grafana_api_key: "..."
    dashboard_id: 468
    panel_id: 20
    text: "Annotation description"
    tags:
      - tag1
      - tag2

aorfanos avatar Dec 22 '20 08:12 aorfanos

@aorfanos I used to have a module to do that but I’m not sure it is still working : https://github.com/rrey/ansible-module-grafana-annotations It could be a good reason to add it in the collection and maintain it !

rrey avatar Dec 22 '20 09:12 rrey

Another small note on that: In my module I implemented 'annotate dashboard by name' functionality, so if we could have the same in the community module it would be amazing :)

Example usage:

- name: Create a Grafana annotation
  add_grafana_annotation:
    grafana_api_url: "https://grafana.myproject.com"
    grafana_api_key: "..."
    dashboard_name: "AlertManager Overview"
    panel_id: 1
    text: "Annotation description"
    tags:
      - tag1

aorfanos avatar Dec 31 '20 13:12 aorfanos