상관관계(Correlations) API
상관관계(Correlations) API
이 API는 데이터 소스 간의 상관관계를 정의하는 데 사용할 수 있어요.
⚠️ Grafana 13부터
/api엔드포인트가/apis라우트로 대체되어 더 이상 사용되지 않게(deprecated) 되고 있어요. Grafana가 기존 API를 마이그레이션하는 동안 현재 사용 중인 레거시 API와 정확히 일치하지 않을 수 있어요. 이 변경으로 현재 설정이 중단되거나 깨지지는 않아요. 레거시 API는 비활성화되지 않으며 완전히 접근·사용 가능하지만,/api라우트는 더 이상 업데이트되지 않아요. 자세한 내용은 "Grafana의 새 API 구조" 문서를 참조해요.
출처: 문서
본문
상관관계 생성
POST /api/datasources/uid/:sourceUID/correlations
두 데이터 소스 간의 상관관계를 생성해요 — 경로의 sourceUID로 식별되는 소스 데이터 소스와 body에 지정된 대상 데이터 소스.
예제 요청:
POST /api/datasources/uid/uyBf2637k/correlations HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>
{
"targetUID": "PDDA8E780A17E7EF1",
"label": "My Label",
"description": "Logs to Traces",
"type": "query",
"config": {
"field": "message",
"target": {},
}
}
JSON body 스키마:
targetUID– 대상 데이터 소스 uid.label– 상관관계에 대한 레이블.description– 상관관계에 대한 설명.
예제 응답:
HTTP/1.1 200
Content-Type: application/json
{
"message": "Correlation created",
"result": {
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
"uid": "50xhMlg9k",
"type": "query",
"config": {
"field": "message",
"target": {},
}
}
}
상태 코드:
- 200 – OK
- 400 – Errors (잘못된 JSON, 누락되거나 잘못된 필드)
- 401 – Unauthorized
- 403 – Forbidden, 소스 데이터 소스가 읽기 전용
- 404 – Not found, 소스 또는 대상 데이터 소스를 찾을 수 없음
- 500 – Internal error
상관관계 삭제
DELETE /api/datasources/uid/:sourceUID/correlations/:correlationUID
상관관계를 삭제해요.
예제 요청:
DELETE /api/datasources/uid/uyBf2637k/correlations/J6gn7d31L HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...>
예제 응답:
HTTP/1.1 200
Content-Type: application/json
{
"message": "Correlation deleted"
}
상태 코드:
- 200 – OK
- 401 – Unauthorized
- 403 – Forbidden, 데이터 소스가 읽기 전용
- 404 – Correlation not found
- 500 – Internal error
상관관계 업데이트
PATCH /api/datasources/uid/:sourceUID/correlations/:correlationUID
상관관계를 업데이트해요.
예제 요청:
POST /api/datasources/uid/uyBf2637k/correlations/J6gn7d31L HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>
{
"label": "My Label",
"description": "Logs to Traces",
}
JSON body 스키마:
label– 상관관계에 대한 레이블.description– 상관관계에 대한 설명.
예제 응답:
HTTP/1.1 200
Content-Type: application/json
{
"message": "Correlation updated",
"result": {
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
"uid": "J6gn7d31L",
"type": "query",
"config": {
"field": "message",
"target": {}
}
}
}
상태 코드:
- 200 – OK
- 400 – Bad request
- 401 – Unauthorized
- 403 – Forbidden, 소스 데이터 소스가 읽기 전용
- 404 – Not found, 소스 또는 대상 데이터 소스를 찾을 수 없음
- 500 – Internal error
단일 상관관계 가져오기
GET /api/datasources/uid/:sourceUID/correlations/:correlationUID
단일 상관관계를 가져와요.
예제 요청:
GET /api/datasources/uid/uyBf2637k/correlations/J6gn7d31L HTTP/1.1
Accept: application/json
Authorization: Bearer <SERVI...>
예제 응답:
HTTP/1.1 200
Content-Type: application/json
{
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
"uid": "J6gn7d31L",
"provisioned": false,
"type": "query",
"config": {
"field": "message",
"target": {},
}
}
상태 코드:
- 200 – OK
- 401 – Unauthorized
- 404 – Not found, 소스 데이터 소스 또는 상관관계를 찾을 수 없음
- 500 – Internal error
주어진 데이터 소스에서 시작하는 모든 상관관계 가져오기
GET /api/datasources/uid/:sourceUID/correlations
경로의 주어진 sourceUID로 식별되는 데이터 소스에서 시작하는 모든 상관관계를 가져와요.
예제 요청:
GET /api/datasources/uid/uyBf2637k/correlations HTTP/1.1
Accept: application/json
Authorization: Bearer <SERVI...>
예제 응답:
HTTP/1.1 200
Content-Type: application/json
[
{
"description": "Logs to Traces",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
"uid": "J6gn7d31L",
"provisioned": false,
"type": "query",
"config": {
"field": "message",
"target": {},
}
},
{
"description": "Logs to Metrics",
"label": "Another Label",
"sourceUID": "uyBf2637k",
"targetUID": "P15396BDD62B2BE29",
"uid": "uWCpURgVk",
"provisioned": false,
"type": "query",
"config": {
"field": "message",
"target": {},
}
}
]
상태 코드:
- 200 – OK
- 401 – Unauthorized
- 404 – Not found, 소스 데이터 소스를 찾을 수 없거나 주어진 데이터 소스에서 시작하는 상관관계가 없음
- 500 – Internal error
모든 상관관계 가져오기
GET /api/datasources/correlations
모든 상관관계를 가져와요.
쿼리 매개변수:
page- 선택 사항. 반환할 페이지 번호를 지정해요. 페이지당 상관관계 수를 지정하려면 limit 매개변수를 사용해요. 기본값은 page 1.limit- 선택 사항. 페이지당 반환되는 상관관계 수를 제한해요. 기본값은 페이지당 100개, 페이지당 최대 1000개.sourceUID- 선택 사항. 필터링할 소스 데이터 소스 UID를 지정해요. 여러 데이터 소스로 필터링하려면 이 값을 반복할 수 있어요.
예제 요청:
GET /api/datasources/correlations HTTP/1.1
Accept: application/json
Authorization: Bearer <SERVI...>
예제 응답:
HTTP/1.1 200
Content-Type: application/json
[
{
"description": "Prometheus to Loki",
"label": "My Label",
"sourceUID": "uyBf2637k",
"targetUID": "PDDA8E780A17E7EF1",
"uid": "J6gn7d31L",
"provisioned": false,
"type": "query",
"config": {
"field": "message",
"target": {},
}
},
{
"description": "Loki to Tempo",
"label": "Another Label",
"sourceUID": "PDDA8E780A17E7EF1",
"targetUID": "P15396BDD62B2BE29",
"uid": "uWCpURgVk",
"provisioned": false,
"type": "query",
"config": {
"field": "message",
"target": {},
}
}
]
상태 코드:
- 200 – OK
- 401 – Unauthorized
- 404 – Not found, 상관관계를 찾을 수 없음
- 500 – Internal error
더 알아보기 (Learn more)
- 데이터 소스 간 상관관계 구성
- Grafana의 새 API 구조