Query a datasource
query_datasourceRun read-only queries against Grafana datasources using unified API. Supports PromQL, LogQL, and SQL to retrieve result frames.
Instructions
Run a query against a datasource through Grafana's unified query API and return the result frames. For Prometheus/Loki set expr (PromQL / LogQL); for SQL datasources set rawSql. Reading data only — this never mutates anything. Use a bounded time range and a small maxDataPoints to keep results manageable.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Range end, e.g. 'now'. Default now. | |
| expr | No | PromQL or LogQL expression, e.g. 'up' or 'rate(http_requests_total[5m])'. | |
| from | No | Range start, e.g. 'now-1h' or an epoch ms string. Default now-1h. | |
| rawSql | No | SQL for SQL datasources (a single read-only SELECT). | |
| datasourceUid | Yes | Datasource UID (from list_datasources). | |
| maxDataPoints | No | Cap on returned points. Default 100. |