Programmatic metric queries from dashboard and datasource info

I’d like to be able to use Grafana as an intermediate data source for another application that will consume the metric data, without knowing about the type of the datasource in advance. For instance, if I had a dashboard with some metrics from Graphite and some other ones from CloudWatch, I want code that can determine how to get the timeseries data from both Graphite and CloudWatch without writing anything that’s Graphite or CloudWatch specific. In the docs, I see two APIs that can get me part of the way there:

A. Get dashboard should help me find out what queries are being made from the dashboard
C. Data source proxy calls should help me query the underlying data source for the timeseries data

But there seems to be a missing (B) and (D), namely:

B. How do I determine how to structure the query to the underlying data source?
D. How do I determine how to parse out the timeseries that comes back from the data source into a standard format?

I know Grafana is really designed more as a visualization tool than as a data source itself, so I’m slightly afraid (B) and (D) are done purely through front end plugin code and there’s no API that will let me do it programmatically, but it would be awseome if it’s possible. So:

  1. Any ideas on how to accomplish (B) and (D) programmatically?
  2. If not, is there some other way to accomplish the overall goal (given a dashboard, give me the timeseries data for it without coding special cases for all possible data sources)?
1 Like

The only way to to do that is writing a custom panel in Grafana. Grafana panels can query time series databases and get back a standard time series format without knowing the details of the time series databases.

There is no HTTP APi for this though as the data sources are written in the frontend and they query and transform data to the format panels expect.-

1 Like

Yeah, for my purposes it’s unfortunate that all the “translation” is done frontend, but it’s what I expected (/feared)- thanks for confirming! A custom panel which gets the “translated” timeseries and then pushes it somewhere is a good idea. The only reason it won’t work for my case is that I need to be able to get the timeseries even when nobody has a panel pulled up.

Hi,

I’m trying to do something similar (I need to combine data from two different data sources in my custom front end panel). After reading your responses I’m still not clear how can I do this.
If data-source-proxy-calls is the ultimate solution, can you please tell me how should the request be made and what will be the response? I don’t see this information in the hyperlinked page. Thanks.