From 134e93db78376c3db3df594fb2d4e28f79772a85 Mon Sep 17 00:00:00 2001 From: Manuel Pintaldi Date: Tue, 12 Nov 2019 18:28:13 +0100 Subject: [PATCH] add uid --- grafana_dashboards/client/grafana.py | 3 +++ grafana_dashboards/components/dashboards.py | 2 ++ samples/project.yaml | 1 + 3 files changed, 6 insertions(+) diff --git a/grafana_dashboards/client/grafana.py b/grafana_dashboards/client/grafana.py index 046d5e7..a18bea8 100644 --- a/grafana_dashboards/client/grafana.py +++ b/grafana_dashboards/client/grafana.py @@ -51,5 +51,8 @@ def process_dashboard(self, project_name, dashboard_name, dashboard_data): if 'folderId' in dashboard_data: body.update({'folderId': dashboard_data['folderId']}) + if 'uid' in dashboard_data: + body.update({'uid': dashboard_data['uid']}) + logger.info("Uploading dashboard '%s' to %s", dashboard_name, self._host) self._connection.make_request('/api/dashboards/db', body) diff --git a/grafana_dashboards/components/dashboards.py b/grafana_dashboards/components/dashboards.py index 7ac9975..caf4a72 100644 --- a/grafana_dashboards/components/dashboards.py +++ b/grafana_dashboards/components/dashboards.py @@ -54,6 +54,8 @@ def gen_json_from_data(self, data, context): json_data['refresh'] = data.get('refresh') if 'folderId' in data: json_data['folderId'] = data.get('folderId') + if 'uid' in data: + json_data['uid'] = data.get('uid') if get_component_type(Annotations) in data: json_data['annotations'] = {'list': self.registry.create_component(Annotations, data).gen_json()} if get_component_type(Rows) in data: diff --git a/samples/project.yaml b/samples/project.yaml index f322522..b01b6f9 100644 --- a/samples/project.yaml +++ b/samples/project.yaml @@ -20,6 +20,7 @@ - name: overview dashboard: + uid: 'uid{dashboard-prefix}' title: '{dashboard-prefix} Overview' tags: - tag1