summaryrefslogtreecommitdiff
path: root/roles/monitoring/grafana/tasks
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2024-06-19 21:08:54 +0200
committerChristian Pointner <equinox@spreadspace.org>2024-06-19 21:08:54 +0200
commit02fa342e7d98365b7bde8a390e0432249aaf12a1 (patch)
tree875d98e8ab02cf8cb9565b05f81c207bab7ea0f4 /roles/monitoring/grafana/tasks
parentprometheus: revamp labels for metrcis from blackbox exporter (diff)
grafana: create new dashboards for revamped blackbox exporter metric labels
Diffstat (limited to 'roles/monitoring/grafana/tasks')
-rw-r--r--roles/monitoring/grafana/tasks/main.yml24
1 files changed, 12 insertions, 12 deletions
diff --git a/roles/monitoring/grafana/tasks/main.yml b/roles/monitoring/grafana/tasks/main.yml
index de2857df..5d6c9c17 100644
--- a/roles/monitoring/grafana/tasks/main.yml
+++ b/roles/monitoring/grafana/tasks/main.yml
@@ -118,20 +118,28 @@
mode: 0640
notify: restart grafana
-- name: create directory for dashboards
+- name: create base directory for dashboards
file:
path: /var/lib/grafana/dashboards/ansible
state: directory
group: grafana
mode: 0750
+- name: create sub-directories for dashboards
+ loop: "{{ grafana_dashboards | grafana_dashboard_subdirs }}"
+ file:
+ path: "/var/lib/grafana/dashboards/ansible/{{ item }}"
+ state: directory
+ group: grafana
+ mode: 0750
+
- name: install dashboards from file
loop: "{{ grafana_dashboards | selectattr('file', 'defined') }}"
loop_control:
label: "{{ item.file }} -> {{ item.datasource }}"
copy:
content: "{{ lookup('file', 'dashboard-'+item.file+'.json') | regex_replace('\"(?:\\${)?DS_[A-Z0-9_-]+(?:})?\"', '\"'+item.datasource+'\"') }}\n"
- dest: "/var/lib/grafana/dashboards/ansible/{{ item.datasource }}_{{ item.file }}.json"
+ dest: "/var/lib/grafana/dashboards/ansible/{{ item | grafana_dashboard_dest }}.json"
register: grafana_dasboards_from_file
- name: install dashboards from content
@@ -140,22 +148,14 @@
label: "{{ item.name }} -> {{ item.datasource }}"
copy:
content: "{{ item.content | regex_replace('\"(?:\\${)?DS_[A-Z0-9_-]+(?:})?\"', '\"'+item.datasource+'\"') }}\n"
- dest: "/var/lib/grafana/dashboards/ansible/{{ item.datasource }}_{{ item.name }}.json"
+ dest: "/var/lib/grafana/dashboards/ansible/{{ item | grafana_dashboard_dest }}.json"
register: grafana_dasboards_from_content
- ## TODO: implement this
-- name: install dashboards from grafana.com
- loop: "{{ grafana_dashboards | selectattr('id', 'defined') }}"
- loop_control:
- label: "https://grafana.com/api/dashboards/{{ item.id }} -> {{ item.datasource }}"
- debug:
- msg: 'installing dashboards from grafana.com is not yet supported!'
- # register: grafana_dasboards_from_grafanacom
-
- name: fetch list of installed dashboards
find:
paths: /var/lib/grafana/dashboards/ansible
patterns: "*.json"
+ recurse: true
register: grafana_dashboards_installed
- name: remove superfluous dashboards