mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 08:42:33 +08:00
Plugins: Remove deprecated /api/tsdb/query metrics endpoint (#49916)
* remove /api/tsdb/query * revert changes to alert rules * regenerate spec based on 9.0.x
This commit is contained in:
@ -960,117 +960,3 @@ In addition, specific properties of each data source should be added in a reques
|
||||
| 403 | Access denied. |
|
||||
| 404 | Either the data source or plugin required to fulfil the request could not be found. |
|
||||
| 500 | Unexpected error. Refer to the body and/or server logs for more details. |
|
||||
|
||||
## Deprecated resources
|
||||
|
||||
The following resources have been deprecated. They will be removed in a future release.
|
||||
|
||||
### Query a data source by id
|
||||
|
||||
> **Warning:** This API is deprecated since Grafana v8.5.0 and will be removed in a future release. Refer to the [new data source query API](#query-a-data-source).
|
||||
|
||||
Queries a data source having a backend implementation.
|
||||
|
||||
`POST /api/tsdb/query`
|
||||
|
||||
> **Note:** Grafana's built-in data sources usually have a backend implementation.
|
||||
|
||||
**Example Request**:
|
||||
|
||||
```http
|
||||
POST /api/tsdb/query HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"from": "1420066800000",
|
||||
"to": "1575845999999",
|
||||
"queries": [
|
||||
{
|
||||
"refId": "A",
|
||||
"intervalMs": 86400000,
|
||||
"maxDataPoints": 1092,
|
||||
"datasourceId": 86,
|
||||
"rawSql": "SELECT 1 as valueOne, 2 as valueTwo",
|
||||
"format": "table"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
JSON Body schema:
|
||||
|
||||
- **from/to** – Specifies the time range for the queries. The time can be either epoch timestamps in milliseconds or relative using Grafana time units. For example, `now-5m`.
|
||||
- **queries.refId** – Specifies an identifier of the query. Defaults to "A".
|
||||
- **queries.format** – Specifies the format the data should be returned in. Valid options are `time_series` or `table` depending on the data source.
|
||||
- **queries.datasourceId** – Specifies the data source to be queried. Each `query` in the request must have a unique `datasourceId`.
|
||||
- **queries.maxDataPoints** - Species the maximum amount of data points that a dashboard panel can render. Defaults to 100.
|
||||
- **queries.intervalMs** - Specifies the time series time interval in milliseconds. Defaults to 1000.
|
||||
|
||||
In addition, specific properties of each data source should be added in a request. To better understand how to form a query for a certain data source, use the Developer Tools in your browser of choice and inspect the HTTP requests being made to `/api/tsdb/query`.
|
||||
|
||||
**Example request for the MySQL data source:**
|
||||
|
||||
```http
|
||||
POST /api/tsdb/query HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"from": "1420066800000",
|
||||
"to": "1575845999999",
|
||||
"queries": [
|
||||
{
|
||||
"refId": "A",
|
||||
"intervalMs": 86400000,
|
||||
"maxDataPoints": 1092,
|
||||
"datasourceId": 86,
|
||||
"rawSql": "SELECT\n time,\n sum(opened) AS \"Opened\",\n sum(closed) AS \"Closed\"\nFROM\n issues_activity\nWHERE\n $__unixEpochFilter(time) AND\n period = 'm' AND\n repo IN('grafana/grafana') AND\n opened_by IN('Contributor','Grafana Labs')\nGROUP BY 1\nORDER BY 1\n",
|
||||
"format": "time_series"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Example MySQL time series query response:**
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"results": {
|
||||
"A": {
|
||||
"refId": "A",
|
||||
"meta": {
|
||||
"rowCount": 0,
|
||||
"sql": "SELECT\n time,\n sum(opened) AS \"Opened\",\n sum(closed) AS \"Closed\"\nFROM\n issues_activity\nWHERE\n time >= 1420066800 AND time <= 1575845999 AND\n period = 'm' AND\n repo IN('grafana/grafana') AND\n opened_by IN('Contributor','Grafana Labs')\nGROUP BY 1\nORDER BY 1\n"
|
||||
},
|
||||
"series": [
|
||||
{
|
||||
"name": "Opened",
|
||||
"points": [
|
||||
[
|
||||
109,
|
||||
1420070400000
|
||||
],
|
||||
[
|
||||
122,
|
||||
1422748800000
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Closed",
|
||||
"points": [
|
||||
[
|
||||
89,
|
||||
1420070400000
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user