Extend support for custom Grafana dashboards

The current behaviour is to support supplying a single
folder of Grafana dashboards which can then be populated
into a single folder in Grafana. Some users may wish
to have sub-folders of Dashboards, and load these into
separate dashboard folders in Grafana via a custom
provisioning file. For example, a user may have a
sub-folder of Ceph dashboards that they wish to keep
separate from OpenStack dashboards. This patch supports
sub-folders whilst not affecting the original mechanism.

Trivial-Fix

Change-Id: I9cd289a1ea79f00cee4d2ef30cbb508ac73f9767
This commit is contained in:
Doug Szumski 2021-04-13 15:19:12 +00:00
parent 09fcfe8cd2
commit d01192c160
2 changed files with 7 additions and 21 deletions

View File

@ -139,26 +139,12 @@
- inventory_hostname in groups[service.group] - inventory_hostname in groups[service.group]
- service.enabled | bool - service.enabled | bool
- name: Create custom Grafana dashboards folder
become: true
vars:
service: "{{ grafana_services['grafana'] }}"
file:
dest: "{{ node_config_directory }}/grafana/dashboards/"
state: "directory"
mode: "0770"
when:
- grafana_custom_dashboards_folder.stat.exists
- grafana_custom_dashboards_folder.stat.isdir
- inventory_hostname in groups[service.group]
- service.enabled | bool
- name: Copying over custom dashboards - name: Copying over custom dashboards
vars: vars:
service: "{{ grafana_services['grafana'] }}" service: "{{ grafana_services['grafana'] }}"
copy: copy:
src: "{{ item }}" src: "{{ node_custom_config }}/grafana/dashboards"
dest: "{{ node_config_directory }}/grafana/dashboards/" dest: "{{ node_config_directory }}/grafana/"
mode: "0660" mode: "0660"
become: true become: true
when: when:
@ -166,7 +152,5 @@
- grafana_custom_dashboards_folder.stat.isdir - grafana_custom_dashboards_folder.stat.isdir
- inventory_hostname in groups[service.group] - inventory_hostname in groups[service.group]
- service.enabled | bool - service.enabled | bool
with_fileglob:
- "{{ node_custom_config }}/grafana/dashboards/*.json"
notify: notify:
- Restart grafana container - Restart grafana container

View File

@ -35,9 +35,11 @@ Custom dashboards provisioning
Kolla Ansible sets custom dashboards provisioning using `Dashboard provider <https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards>`_. Kolla Ansible sets custom dashboards provisioning using `Dashboard provider <https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards>`_.
Dashboard's JSON files should be placed into Dashboard JSON files should be placed into the
``{{ node_custom_config }}/grafana/dashboards/`` folder. ``{{ node_custom_config }}/grafana/dashboards/`` folder. The use of
Dashboards will be imported to Grafana dashboards General Folder. sub-folders is also supported when using a custom ``provisioning.yaml``
file. Dashboards will be imported into the Grafana dashboards 'General'
folder by default.
Grafana provisioner config can be altered by placing ``provisioning.yaml`` to Grafana provisioner config can be altered by placing ``provisioning.yaml`` to
``{{ node_custom_config }}/grafana/`` folder. ``{{ node_custom_config }}/grafana/`` folder.