Pulling Data from a dashboard programmatically

  • What Grafana version and what operating system are you using?
    6.7.2

  • What are you trying to achieve?
    My apologies if this is a very basic, but I am very new to Grafana and I’m trying to get my feet underneath me. Basically, I’ve got an ELK stack set up and I am curious if there is a way to programmatically connect to Grafana and pull some or all data from a specific dashboard. For example, I’ve got a dashboard that displays CPU Utilization, Memory Utilization, and Disk I/O for a given timeframe. Is there a way that I could write a Golang program, or use curl to pull down just the CPU data from time X to Time Y?

  • How are you trying to achieve it?
    Ideally, if there is a Golang plugin, I’d like to use that. However, if that is not that on the table, I’m open to however this can be done.

  • What happened?
    I don’t actually have a plan for how to make this work. I’m looking to see if this is actually possible.

  • What did you expect to happen?
    N/A

  • Can you copy/paste the configuration(s) that you are having problems with?
    N/A

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    N/A

  • Did you follow any online instructions? If so, what is the URL?
    N/A

Hi @philr

Have you tried adding the elasticsearch datasource to Grafana and writing some queries?

Thanks, @mattabrams! That’s a really good idea. I’ve started looking into that and it’s a little more complicated than I had anticipated. Please let me approach this from a different angle.

I have been poking around on the UI a bit and I’ve noticed that I can drill down into a specific view in the dashboard and from there, I can click on the title, then select More → Export CSV. Like this:

ExportCSV

That might actually do what I need it to do. Is there a way to do that programmatically?

Thanks!

Hi @philr,

It doesn’t look like we have an HTTP API endpoint for triggering the CSV export. Short of that feature, I think you’d have to use some headless browser API like puppeteer to perform that specific action programmatically.

In the newer version of Grafana Enterprise, there is a reporting feature, but that’s not what you want.

Because Grafana is just a visualization layer that sits on top of datasources, it might be best to script something that calls the datasource directly, if you just want the raw data…I hope this helps!

1 Like

That’s a bit of a bummer, but thanks for the definitive answer.

Back to the queries!

1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.