question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish to Grafana instance using REST API

See original GitHub issue

Really great library. I would like to get some thoughts on a potential feature. For development, it would be useful to be able to directly publish to a Grafana instance to preview/test using the REST API. This is especially useful if you don’t have access to the data sources locally.

API could take the form of a method

class Dashboard:
    ...
    def preview(self, grafana_url: str, grafana_auth: str, folder: Optional[str] = None) -> str:
       ....

preview would create (or update, if it exists based on title) a dashboard named {self.title} (Preview), and would return the URL to the preview dashboard. This could also return a context manager that would delete the preview dashboard on __exit__, so that you could do:

with dashboard.preview(...) as preview:
   webbrowser.open(preview.url)
   _ = input() # Wait for a keystroke, then cleanup

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesGibocommented, Jan 25, 2021

Yeah, I like the idea.

For me the the ability to preview a dashboard from the a Python file would be more useful than from a Jupyter notebook.

If we go to the effort of adding support for grafanalib to preview a grafana dashboard we might as well add support for it to publish/provision dashboards as the process will be almost the same.

https://grafana.com/docs/grafana/latest/http_api/dashboard/

Here is some Python code from Ansible for creating/updating dashboards: https://github.com/ansible-collections/community.grafana/blob/770421f3f227f19c0cb227fdbf681be80d69225a/plugins/modules/grafana_dashboard.py#L295-L315

0reactions
JamesGibocommented, May 20, 2021

#370 example code to publish a dashboard in python

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP API | Grafana documentation
The Grafana backend exposes an HTTP API, which is the same API that is used by the frontend to do everything from saving...
Read more >
Data source HTTP API | Grafana documentation
Data source API ; Example Request · GET /api/datasources/id/test_datasource HTTP/1.1 Accept: application/json · Example Response ; Example Request · DELETE /api/ ...
Read more >
Create API tokens and dashboards for an organization - Grafana
Create API tokens and dashboards for an organization Use the Grafana API to set up new Grafana organizations or to add dynamically generated...
Read more >
User HTTP API | Grafana documentation
Requires basic authentication and that the authenticated user is a Grafana Admin. Example Request: POST /api/users/7/using/2 HTTP/1.1 ...
Read more >
Grafana Cloud API
Create Hosted Grafana instance API keys. POST https://grafana.com/api/instances/<stack_slug>/api/auth/keys. This creates API keys specific to use for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found