v1

latestSwagger 2.02026-07-17290378721.8 KB
ds

DataSource query metrics with expressions.

If you are running Grafana Enterprise and have Fine-grained access control enabled you need to have a permission with action: datasources:query.

post/ds/query

Request body

debugboolean
fromstring required

From Start time in epoch timestamps in milliseconds or relative using Grafana time units.

publicDashboardAccessTokenstring
queriesJson[] required

queries.refId – Specifies an identifier of the query. Is optional and default to “A”. queries.datasourceId – Specifies the data source to be queried. Each query in the request must have an unique datasourceId. queries.maxDataPoints - Species maximum amount of data points that dashboard panel can render. Is optional and default to 100. queries.intervalMs - Specifies the time interval in milliseconds of time series. Is optional and defaults to 1000.

tostring required

To End time in epoch timestamps in milliseconds or relative using Grafana time units.

Example request

{
  "from": "now-1h",
  "queries": [
    {
      "datasource": {
        "uid": "PD8C576611E62080A"
      },
      "format": "table",
      "intervalMs": 86400000,
      "maxDataPoints": 1092,
      "rawSql": "SELECT 1 as valueOne, 2 as valueTwo",
      "refId": "A"
    }
  ],
  "to": "now"
}

Response

(empty)

ResponsesResponses

The QueryData method the QueryDataHandler method will set the RefId property on the DataResponses' frames based on these RefIDs.