Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Updating dashboards will cause them to move to the "General" folder #82

Open
amotl opened this issue Oct 27, 2020 · 6 comments · Fixed by grafana-toolbox/grafana-client#7 · May be fixed by #85
Open

Updating dashboards will cause them to move to the "General" folder #82

amotl opened this issue Oct 27, 2020 · 6 comments · Fixed by grafana-toolbox/grafana-client#7 · May be fixed by #85

Comments

@amotl
Copy link

amotl commented Oct 27, 2020

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 grafana-toolbox/grafana-wtf#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.

@amotl amotl changed the title [Grafana 7] Updating dashboards will cause them to change folder Updating dashboards will cause them to change folder Jan 5, 2021
@amotl
Copy link
Author

amotl commented Jan 5, 2021

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

@amotl amotl changed the title Updating dashboards will cause them to change folder Updating dashboards will cause them to move to the "General" folder Jan 5, 2021
@amotl
Copy link
Author

amotl commented Jan 5, 2021

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.

@amotl amotl linked a pull request Jan 5, 2021 that will close this issue
@amotl
Copy link
Author

amotl commented Jan 6, 2021

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.

@JackNelson
Copy link

+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"

@amotl
Copy link
Author

amotl commented Oct 1, 2021

Dear Jack,

see #85 (comment) for a workaround.

With kind regards,
Andreas.

@amotl
Copy link
Author

amotl commented Feb 6, 2022

Hi again,

we integrated this patch into the grafana-client code base with grafana-toolbox/grafana-client#7.

With kind regards,
Andreas.

@amotl amotl reopened this Feb 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants