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:
Giordano Ricci
2022-08-11 16:58:11 +01:00
committed by GitHub
parent 8813cbfb62
commit c1b30c56c9
10 changed files with 917 additions and 3 deletions

View File

@ -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