1
0
Fork 0
mirror of synced 2024-11-22 08:55:35 -05:00

Manage dashboards only for the current datasource

This change adds a new 'datasource' parameter to the dashboard metadata.
This way, the Grafana client state will manage only the dashboards that
match with the deployed datasource (either InfluxDB or Prometheus). For
backward compatibility, the client will always manage the dashboards
that don't set this new parameter.

Change-Id: Iac323d756aff6ca4180f4b648a1d02692ebf292b
This commit is contained in:
Simon Pasquier 2017-05-24 10:33:54 +02:00
parent 2127f4e493
commit f6e5544264
2 changed files with 7 additions and 0 deletions

View file

@ -1,8 +1,10 @@
{%- from "grafana/map.jinja" import client with context %} {%- from "grafana/map.jinja" import client with context %}
{%- if client.get('enabled', False) %} {%- if client.get('enabled', False) %}
{%- set datasources = [] %}
{%- for datasource_name, datasource in client.datasource.iteritems() %} {%- for datasource_name, datasource in client.datasource.iteritems() %}
{%- do datasources.append(datasource.type) %}
grafana_client_datasource_{{ datasource_name }}: grafana_client_datasource_{{ datasource_name }}:
grafana3_datasource.present: grafana3_datasource.present:
- name: {{ datasource.name|default(datasource_name) }} - name: {{ datasource.name|default(datasource_name) }}
@ -63,6 +65,7 @@ grafana_client_datasource_{{ datasource_name }}:
{%- endfor %} {%- endfor %}
{%- for dashboard_name, dashboard in final_dict.iteritems() %} {%- for dashboard_name, dashboard in final_dict.iteritems() %}
{%- if dashboard.datasource is not defined or dashboard.datasource in datasources %}
{%- if dashboard.get('enabled', True) %} {%- if dashboard.get('enabled', True) %}
grafana_client_dashboard_{{ dashboard_name }}: grafana_client_dashboard_{{ dashboard_name }}:
grafana3_dashboard.present: grafana3_dashboard.present:
@ -88,6 +91,7 @@ grafana_client_dashboard_{{ dashboard_name }}:
grafana3_dashboard.absent: grafana3_dashboard.absent:
- name: {{ dashboard_name }} - name: {{ dashboard_name }}
{%- endif %} {%- endif %}
{%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}

View file

@ -1,13 +1,16 @@
dashboard: dashboard:
grafana: grafana:
datasource: influxdb
format: json format: json
template: grafana/files/grafana_dashboards/grafana_influxdb.json template: grafana/files/grafana_dashboards/grafana_influxdb.json
main: main:
datasource: influxdb
format: yaml format: yaml
base_dashboards: ['grafana:client:base_templates:main_dashboard'] base_dashboards: ['grafana:client:base_templates:main_dashboard']
base_rows: ['grafana:client:base_templates:service_row'] base_rows: ['grafana:client:base_templates:service_row']
base_panels: ['grafana:client:base_templates:cluster_status_singlestat'] base_panels: ['grafana:client:base_templates:cluster_status_singlestat']
service_level: service_level:
datasource: influxdb
format: yaml format: yaml
base_dashboards: ['grafana:client:base_templates:service_level_dashboard'] base_dashboards: ['grafana:client:base_templates:service_level_dashboard']
base_rows: ['grafana:client:base_templates:service_level_row'] base_rows: ['grafana:client:base_templates:service_level_row']