Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: library panels not geting imported over dashboard API #43525

Closed
wants to merge 1 commit into from

Conversation

efekete
Copy link

@efekete efekete commented Dec 24, 2021

What this PR does / why we need it:
fix for library panels not getting imported over dashboard API
original feature for import/export of library panels (over Grafana UI) is here:
#39214

Fixes #
#44003
Special notes for your reviewer:

@efekete efekete requested a review from a team as a code owner December 24, 2021 16:34
@efekete efekete requested review from papagian, kylebrandt and kminehart and removed request for a team December 24, 2021 16:34
@CLAassistant
Copy link

CLAassistant commented Dec 24, 2021

CLA assistant check
All committers have signed the CLA.

@hugohaggmark
Copy link
Contributor

Hi @efekete can you explain in more detail in what use case this fix is necessary?

@efekete
Copy link
Author

efekete commented Jan 10, 2022

Hi @hugohaggmark

so the problem you solved (in above linked PR) was importing dashboard panels while importing the dashboard itself. It all works great when we are importing dashboard through UI. The problem we ran into was when we tried using a tool like https://github.com/netsage-project/gdg.
It uses dashboard API and there import of panels is not implemented. The import works well, but the panels that dashboard is referring does not exist and therefor can not be used. This PR should fix that issue.

@hugohaggmark
Copy link
Contributor

Hi @hugohaggmark

so the problem you solved (in above linked PR) was importing dashboard panels while importing the dashboard itself. It all works great when we are importing dashboard through UI. The problem we ran into was when we tried using a tool like https://github.com/netsage-project/gdg. It uses dashboard API and there import of panels is not implemented. The import works well, but the panels that dashboard is referring does not exist and therefor can not be used. This PR should fix that issue.

Just so I understand, you're using the post dashboard api to import dashboards? There is an import dashboard api for that case. Not sure we'll consider this solution for this use case.

@efekete
Copy link
Author

efekete commented Jan 10, 2022

Can you point me in right direction for that API?

https://grafana.com/docs/grafana/latest/http_api/dashboard/
Here, I only found POST which the tool above use. I don't think it is transparent enough what should be used for what.

I think it would be good feature to import panels even when posting dashboard through dashboard API either way.

@hugohaggmark
Copy link
Contributor

Can you point me in right direction for that API?

https://grafana.com/docs/grafana/latest/http_api/dashboard/ Here, I only found POST which the tool above use. I don't think it is transparent enough what should be used for what.

I think it would be good feature to import panels even when posting dashboard through dashboard API either way.

You're absolutely correct and my vacation was too long it seems 🙈 The import endpoint doesn't seem to be documented at all, maybe this is more important.

@efekete
Copy link
Author

efekete commented Jan 10, 2022

So what would be the best approach to mitigate this issue?

@hugohaggmark
Copy link
Contributor

Maybe someone from @grafana/backend-platform can chime in here?

@efekete
Copy link
Author

efekete commented Jan 10, 2022

Also, if relevant, while trying to import dashboard that has panels that does not exist, I get an error:

time="2022-01-10T21:10:09+01:00" level=info msg="error on Exporting dashboard Apps / Generic per pod HTTP error 500: returns Error while connecting library panels"

One more reason I think this fix should probably be merged.

Although, even when that happen I get dashboard imported, but not fully working.

Screenshot 2022-01-10 at 21 14 51

EDIT: error is from gdg, but only because Grafana returns 500

@hugohaggmark
Copy link
Contributor

Also, if relevant, while trying to import dashboard that has panels that does not exist, I get an error:

When you exported the dashboard did you make sure to export it with Export for sharing externally?
image

@efekete
Copy link
Author

efekete commented Jan 11, 2022

I am not 100% sure, but if I import the same dashboard through Grafana UI, it imports as expected with all library panels imported and linked.
As the code for "dashboard POST" is already linking all the panels present, I do not see the downside of those getting imported before that happens.

@hugohaggmark
Copy link
Contributor

We don't support importing using the dashboard post api so we'll close this issue and PR. We can always revisit this if more feedback is received from the community. Thank you 🙏

@efekete
Copy link
Author

efekete commented Jan 18, 2022

So is there any officially supported API we can use for that?
We have staging and production Grafana with large number of dashboards with shared panels and we want to automate cloning all dashboard to production once we are satisfied with state of those on staging.

@marefr
Copy link
Member

marefr commented Jan 18, 2022

Not really. You have to figure out how to use non-documented POST /api/dashboards/import endpoint that UI are using for importing dashboards. One way figuring that out is to use Chrome Developer Tools or similar and inspect the network interaction when importing a dashboard

@efekete
Copy link
Author

efekete commented Jan 18, 2022

I guess that is ok if you are not planing to remove that API in future. Should I, if I find time, try to write documentation for that or someone else is already working on that?

@marefr
Copy link
Member

marefr commented Jan 18, 2022

We're currently not planning to remove it. Would that change in the future it will follow deprecation notice and breaking change in a major Grafana version. I'm not sure how easy it is to document it, but if you're interested you're welcome to give it a go.

@FrankRough
Copy link

Hi @marefr I am having also issues when creating a regular dashboard when using panel libraries in the JSON
I found another post with similar issues:

https://community.grafana.com/t/issue-with-library-panels/60101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend pr/external This PR is from external contributor
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Importing Dashboard through Grafana API does not import panels
6 participants