mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 01:02:10 +08:00
Correlations: Add GetCorrelation(s) HTTP APIs (#52517)
* Correlations: Get Single correlations * Correlations: Get all correlations for given source ds * Correlations: Get all correlations * add tests * add DB indices * fix lint errors * remove skip from tests * use DatasourceService in test
This commit is contained in:
@ -150,3 +150,126 @@ Status codes:
|
||||
|
||||
- **200** – OK
|
||||
- **401** – Unauthorized
|
||||
- **404** – Not found, either source data source or correlation were not found
|
||||
- **500** – Internal error
|
||||
|
||||
## Get all correlations originating from a given data source
|
||||
|
||||
`GET /api/datasources/uid/:sourceUID/correlations`
|
||||
|
||||
Get all correlations originating from the data source identified by the given `sourceUID` in the path.
|
||||
|
||||
**Example request:**
|
||||
|
||||
```http
|
||||
GET /api/datasources/uid/uyBf2637k/correlations HTTP/1.1
|
||||
Accept: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example response:**
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
[
|
||||
```
|
||||
|
||||
Status codes:
|
||||
|
||||
- **200** – OK
|
||||
- **401** – Unauthorized
|
||||
- **404** – Not found, either source data source is not found or no correlation exists originating from the given data source
|
||||
- **500** – Internal error
|
||||
|
||||
## Get all correlations
|
||||
|
||||
`GET /api/datasources/correlations`
|
||||
|
||||
Get all correlations.
|
||||
|
||||
**Example request:**
|
||||
|
||||
```http
|
||||
GET /api/datasources/correlations HTTP/1.1
|
||||
Accept: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example response:**
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
[
|
||||
```
|
||||
|
||||
Status codes:
|
||||
|
||||
- **200** – OK
|
||||
- **401** – Unauthorized
|
||||
- **404** – Not found, no correlation is found
|
||||
- **500** – Internal error
|
||||
"targetUID": "PDDA8E780A17E7EF1",
|
||||
"uid": "J6gn7d31L"
|
||||
},
|
||||
{
|
||||
"description": "Logs to Metrics",
|
||||
"label": "Another Label",
|
||||
"sourceUID": "uyBf2637k",
|
||||
"targetUID": "P15396BDD62B2BE29",
|
||||
"uid": "uWCpURgVk"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Status codes:
|
||||
|
||||
- **200** – OK
|
||||
- **401** – Unauthorized
|
||||
- **404** – Not found, either source data source is not found or no correlation exists originating from the given data source
|
||||
- **500** – Internal error
|
||||
|
||||
## Get all correlations
|
||||
|
||||
`GET /api/datasources/correlations`
|
||||
|
||||
Get all correlations.
|
||||
|
||||
**Example request:**
|
||||
|
||||
```http
|
||||
GET /api/datasources/correlations HTTP/1.1
|
||||
Accept: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example response:**
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
[
|
||||
{
|
||||
"description": "Prometheus to Loki",
|
||||
"label": "My Label",
|
||||
"sourceUID": "uyBf2637k",
|
||||
"targetUID": "PDDA8E780A17E7EF1",
|
||||
"uid": "J6gn7d31L"
|
||||
},
|
||||
{
|
||||
"description": "Loki to Tempo",
|
||||
"label": "Another Label",
|
||||
"sourceUID": "PDDA8E780A17E7EF1",
|
||||
"targetUID": "P15396BDD62B2BE29",
|
||||
"uid": "uWCpURgVk"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Status codes:
|
||||
|
||||
- **200** – OK
|
||||
- **401** – Unauthorized
|
||||
- **404** – Not found, no correlation is found
|
||||
- **500** – Internal error
|
||||
|
Reference in New Issue
Block a user