2022-07-25 22:19:07 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../../http_api/correlations/
2023-07-21 00:39:59 +08:00
canonical: /docs/grafana/latest/developers/http_api/correlations/
2022-07-25 22:19:07 +08:00
description: Grafana Correlations HTTP API
keywords:
- grafana
- http
- documentation
- api
- correlations
- Glue
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- enterprise
- oss
2022-07-25 22:19:07 +08:00
title: 'Correlations HTTP API '
---
# Correlations API
This API can be used to define correlations between data sources.
## Create correlations
2022-07-27 14:01:46 +08:00
`POST /api/datasources/uid/:sourceUID/correlations`
2022-07-25 22:19:07 +08:00
2022-07-27 14:01:46 +08:00
Creates a correlation between two data sources - the source data source identified by `sourceUID` in the path, and the target data source which is specified in the body.
2022-07-25 22:19:07 +08:00
**Example request:**
```http
POST /api/datasources/uid/uyBf2637k/correlations HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
2022-07-27 14:01:46 +08:00
"targetUID": "PDDA8E780A17E7EF1",
2022-07-25 22:19:07 +08:00
"label": "My Label",
"description": "Logs to Traces",
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-07-25 22:19:07 +08:00
}
```
JSON body schema:
2022-07-27 14:01:46 +08:00
- **targetUID** – Target data source uid.
2022-07-25 22:19:07 +08:00
- **label** – A label for the correlation.
- **description** – A description for the correlation.
**Example response:**
```http
HTTP/1.1 200
Content-Type: application/json
{
"message": "Correlation created",
"result": {
"description": "Logs to Traces",
"label": "My Label",
2022-07-27 14:01:46 +08:00
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
2022-10-04 16:39:55 +08:00
"uid": "50xhMlg9k",
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-07-25 22:19:07 +08:00
}
}
```
Status codes:
- **200** – OK
- **400** - Errors (invalid JSON, missing or invalid fields)
- **401** – Unauthorized
- **403** – Forbidden, source data source is read-only
- **404** – Not found, either source or target data source could not be found
- **500** – Internal error
2022-07-27 16:07:58 +08:00
## Delete correlations
`DELETE /api/datasources/uid/:sourceUID/correlations/:correlationUID`
Deletes a correlation.
**Example request:**
```http
DELETE /api/datasources/uid/uyBf2637k/correlations/J6gn7d31L HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example response:**
```http
HTTP/1.1 200
Content-Type: application/json
{
"message": "Correlation deleted"
}
```
Status codes:
- **200** – OK
- **401** – Unauthorized
- **403** – Forbidden, data source is read-only
- **404** – Correlation not found
- **500** – Internal error
2022-08-03 21:18:51 +08:00
## Update correlations
`PATCH /api/datasources/uid/:sourceUID/correlations/:correlationUID`
Updates a correlation.
**Example request:**
```http
POST /api/datasources/uid/uyBf2637k/correlations/J6gn7d31L HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"label": "My Label",
"description": "Logs to Traces",
}
```
JSON body schema:
- **label** – A label for the correlation.
- **description** – A description for the correlation.
**Example response:**
```http
HTTP/1.1 200
Content-Type: application/json
{
"message": "Correlation updated",
"result": {
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
2022-10-04 16:39:55 +08:00
"uid": "J6gn7d31L",
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {}
}
2022-08-03 21:18:51 +08:00
}
}
```
Status codes:
- **200** – OK
2022-10-10 21:36:14 +08:00
- **400** – Bad request
2022-08-03 21:18:51 +08:00
- **401** – Unauthorized
- **403** – Forbidden, source data source is read-only
- **404** – Not found, either source or target data source could not be found
- **500** – Internal error
2022-08-11 23:58:11 +08:00
## Get single correlation
`GET /api/datasources/uid/:sourceUID/correlations/:correlationUID`
Gets a single correlation.
**Example request:**
```http
GET /api/datasources/uid/uyBf2637k/correlations/J6gn7d31L HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example response:**
```http
HTTP/1.1 200
Content-Type: application/json
{
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
2022-10-04 16:39:55 +08:00
"uid": "J6gn7d31L",
2023-09-13 21:10:09 +08:00
"provisioned": false,
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-08-11 23:58:11 +08:00
}
```
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
[
{
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
2022-10-04 16:39:55 +08:00
"uid": "J6gn7d31L",
2023-09-13 21:10:09 +08:00
"provisioned": false,
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-08-11 23:58:11 +08:00
},
{
"description": "Logs to Metrics",
"label": "Another Label",
"sourceUID": "uyBf2637k",
"targetUID": "P15396BDD62B2BE29",
2022-10-04 16:39:55 +08:00
"uid": "uWCpURgVk",
2023-09-13 21:10:09 +08:00
"provisioned": false,
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-08-11 23:58:11 +08:00
}
]
```
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.
2023-07-05 22:37:17 +08:00
Query parameters:
- **page** - Optional. Specify which page number to return. Use the limit parameter to specify the number of correlations per page. The default is page 1.
- **limit** - Optional. Limits the number of returned correlations per page. The default is 100 correlations per page. The maximum limit is 1000 correlations in a page.
- **sourceUID** - Optional. Specify a source datasource UID to filter by. This can be repeated to filter by multiple datasources.
2022-08-11 23:58:11 +08:00
**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",
2022-10-04 16:39:55 +08:00
"uid": "J6gn7d31L",
2023-09-13 21:10:09 +08:00
"provisioned": false,
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-08-11 23:58:11 +08:00
},
{
"description": "Loki to Tempo",
"label": "Another Label",
"sourceUID": "PDDA8E780A17E7EF1",
"targetUID": "P15396BDD62B2BE29",
2022-10-04 16:39:55 +08:00
"uid": "uWCpURgVk",
2023-09-13 21:10:09 +08:00
"provisioned": false,
2024-08-26 21:02:48 +08:00
"type": "query",
2022-10-04 16:39:55 +08:00
"config": {
"field": "message",
"target": {},
}
2022-08-11 23:58:11 +08:00
}
]
```
Status codes:
- **200** – OK
- **401** – Unauthorized
- **404** – Not found, no correlation is found
- **500** – Internal error