grafana_api
grafana_api copied to clipboard
Updating dashboards will cause them to move to the "General" folder
Dear Andrew,
first things first: Thank you so much for conceiving and maintaining this library. We are using it in grafana-wtf, which you also might like.
Now, I just found @vinnyfuria reported about Grafana Dashboards being moved to the "General" folder when updating them within https://github.com/panodata/grafana-wtf/issues/5.
Have you also been able to observe this behavior? Maybe it is only happening with Grafana 7? Sorry that I am currently not able to verify this as I don't have access to any Grafana 7 instance yet. I know I could rig up a Docker container for that, but nevertheless I wanted to report this to you in the hope you will be quicker than me.
Thanks already for looking into this and with kind regards, Andreas.
Hi again,
finally, I have been able to dedicate some time to this. I have been able to whip together a reproduction [1] which can be invoked idempotently and I am able to confirm that it happens with all of the most recent Grafana releases of 5.x, 6.x, 7.x.
With kind regards, Andreas.
[1] https://gist.github.com/amotl/43bb89107227431802556b7bcb135578
The solution is to say:
def update_dashboard(self, dashboard):
"""
:param dashboard:
:return:
"""
put_dashboard_path = "/dashboards/db"
if "meta" in dashboard and "folderId" in dashboard["meta"]:
dashboard = dashboard.copy()
dashboard["folderId"] = dashboard["meta"]["folderId"]
r = self.api.POST(put_dashboard_path, json=dashboard)
return r
I will submit a corresponding pull request.
Dear Andrew,
I wish you a happy new year!
As we are currently preparing a new release of grafana-wtf, may I humbly ask you to take a look at #85, where we tried to mitigate this problem which manifests when roundtripping dashboard payloads through get_dashboard() and update_dashboard()?
I tried to supplement the mitigation with appropriate tests and will be happy about any advises from your end.
With kind regards, Andreas.
+1 When can this get merged? Running into a use case for this where I would want to update/create a dashboard to a specific folder and not "General"
Dear Jack,
see https://github.com/m0nhawk/grafana_api/pull/85#issuecomment-932296446 for a workaround.
With kind regards, Andreas.
Hi again,
we integrated this patch into the grafana-client code base with https://github.com/panodata/grafana-client/pull/7.
With kind regards, Andreas.