diff --git a/grafana_dashboards/client/grafana.py b/grafana_dashboards/client/grafana.py index 43d6f2c..e44e0c6 100644 --- a/grafana_dashboards/client/grafana.py +++ b/grafana_dashboards/client/grafana.py @@ -45,5 +45,9 @@ def __init__(self, **kwargs): def process_dashboard(self, project_name, dashboard_name, dashboard_data): super(GrafanaExporter, self).process_dashboard(project_name, dashboard_name, dashboard_data) body = {'overwrite': True, 'dashboard': dashboard_data} + + if 'folderId' in dashboard_data: + body.update({'folderId': dashboard_data['folderId']}) + 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 d6d5e9d..7ac9975 100644 --- a/grafana_dashboards/components/dashboards.py +++ b/grafana_dashboards/components/dashboards.py @@ -52,6 +52,8 @@ def gen_json_from_data(self, data, context): nav['refresh_intervals'] = data.get('refresh_intervals', []) if 'refresh' in data: json_data['refresh'] = data.get('refresh') + if 'folderId' in data: + json_data['folderId'] = data.get('folderId') 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: