diff --git a/grafana_dashboards/parser.py b/grafana_dashboards/parser.py index 4e6e3c2..96dc204 100644 --- a/grafana_dashboards/parser.py +++ b/grafana_dashboards/parser.py @@ -56,6 +56,13 @@ class YamlParser(object): slug = slugify(data['title']) if not self.data.get('dashboard'): self.data['dashboard'] = {} + # The idea is that people work interactively locally using + # the GUI editor, then export the .json using the sharing + # panel. That mostly works, but it can leave a id & uid + # that isn't valid when importing to another grafana + # instance. Remove them. + data.pop('id', None) + data.pop('uid', None) self.data['dashboard'][slug] = data else: result = self.validate(data) diff --git a/tests/fixtures/parser/json-dashboard-0001.json b/tests/fixtures/parser/json-dashboard-0001.json index 2279700..e03593b 100644 --- a/tests/fixtures/parser/json-dashboard-0001.json +++ b/tests/fixtures/parser/json-dashboard-0001.json @@ -137,5 +137,6 @@ "timezone": "", "title": "test json", "uid": "M-GEcyWMk", - "version": 1 + "version": 1, + "id": 1234 } diff --git a/tests/test_parser.py b/tests/test_parser.py index 221cc54..f20920c 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -109,3 +109,5 @@ class TestCaseParser(TestCase): # Get parsed dashboard res, md5 = self.parser.get_dashboard('test-json') self.assertEqual(res['title'], 'test json') + self.assertNotIn('id', res.keys()) + self.assertNotIn('uid', res.keys())