대시보드 API - Amazon Managed Grafana

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

대시보드 API

대시보드 API를 사용하여 Amazon Managed Grafana 워크스페이스에서 대시보드를 생성, 업데이트, 삭제 및 작업할 수 있습니다.

대시보드의 식별자 (id) 는 자동으로 증가하는 숫자 값이며 작업 영역별로 고유합니다. 대시보드의 고유 식별자 (uid) 를 사용하여 여러 Amazon Managed Grafana 작업 영역 간에 대시보드를 고유하게 식별할 수 있습니다. 대시보드를 생성할 때 대시보드를 제공하지 않으면 자동으로 생성됩니다. uid를 사용하면 대시보드에 액세스하고 여러 작업 영역 간에 대시보드를 동기화할 때 일관된 URL을 사용할 수 있습니다. uid를 사용하면 대시보드 제목을 변경해도 북마크된 해당 대시보드 링크가 깨지지 않습니다.

uid의 최대 길이는 40자일 수 있습니다.

참고

아마존 관리형 그라파나 워크스페이스에서 Grafana API를 사용하려면 유효한 Grafana API 토큰이 있어야 합니다. API 요청의 필드에 이를 포함시키세요. Authorization API 호출을 인증하기 위한 토큰을 생성하는 방법에 대한 자세한 내용은 을 참조하십시오토큰으로 인증.

대시보드 생성/업데이트

POST /api/dashboards/db

새 대시보드를 만들거나 기존 대시보드를 업데이트합니다.

새 대시보드 생성 요청 예제

POST /api/dashboards/db HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk { "dashboard": { "id": null, "uid": null, "title": "Production Overview", "tags": [ "templated" ], "timezone": "browser", "schemaVersion": 16, "version": 0, "refresh": "25s" }, "folderId": 0, "folderUid": "l3KqBxCMz", "message": "Made changes to xyz", "overwrite": false }

JSON 본문 스키마:

  • 대시보드 — 완전한 대시보드 모델. null을 사용하여 새 대시보드를 생성합니다.

  • dashboard.id — null을 사용하여 새 대시보드를 만듭니다.

  • dashboard.uid — 이 식별자를 사용하여 새 대시보드를 만들 때 사용할 수 있는 선택적 고유 식별자입니다. null인 경우 새 uid가 생성됩니다.

  • folderid — 대시보드를 저장할 폴더의 ID입니다.

  • FolderUID — 대시보드를 저장할 폴더의 UID입니다. 의 값을 재정의합니다. folderid

  • 덮어쓰기 - 기존 대시보드를 새 버전, 폴더 내 동일한 대시보드 제목 또는 동일한 대시보드 UID로 true 덮어쓰도록 지정합니다.

  • message — 버전 기록에 대한 커밋 메시지를 설정합니다.

  • refresh - 대시보드 새로 고침 간격을 설정합니다. 최소 새로 고침 간격보다 낮으면 무시되고 최소 새로 고침 간격이 사용됩니다.

대시보드 패널에 대한 경고 규칙을 추가하거나 업데이트하려면 dashboard.panels.alert 블록을 선언하십시오.

대시보드 알림 규칙 업데이트 요청 예제

HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 78 { "dashboard": { "id": 104, "panels": [ { "alert": { "alertRuleTags": {}, "conditions": [ { "evaluator": { "params": [ 25 ], "type": "gt" }, "operator": { "type": "and" }, "query": { "params": [ "A", "5m", "now" ] }, "reducer": { "params": [], "type": "avg" }, "type": "query" } ], "executionErrorState": "alerting", "for": "5m", "frequency": "1m", "handler": 1, "name": "Panel Title alert", "noDataState": "no_data", "notifications": [] }, "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": null, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { "h": 9, "w": 12, "x": 0, "y": 0 }, "hiddenSeries": false, "id": 2, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, "nullPointMode": "null", "options": { "dataLinks": [] }, "percentage": false, "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "refId": "A", "scenarioId": "random_walk" } ], "thresholds": [ { "colorMode": "critical", "fill": true, "line": true, "op": "gt", "value": 50 } ], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "Panel Title", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } } ], "title": "Update alert rule via API", "uid": "dHEquNzGz", "version": 1 } }

응답의 예

HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 78 { "id": 1, "uid": "cIBgcSjkk", "url": "/d/cIBgcSjkk/production-overview", "status": "success", "version": 1, "slug": "production-overview" //deprecated in Grafana v5.0 }

상태 코드:

  • 200 — 생성됨

  • 400 — 잘못된 JSON, 유효하지 않거나 누락된 필드 등의 오류

  • 401 — 승인되지 않음

  • 403 — 액세스가 거부되었습니다.

  • 412 — 사전 조건 실패

412 상태 코드는 대시보드를 만들 수 없는 이유를 설명하는 데 사용됩니다.

  • 다른 사람이 대시보드를 변경했습니다. status=version-mismatch

  • 폴더에 이름이 같은 대시보드가 이미 있습니다. status=name-exists

  • 동일한 uid의 대시보드가 이미 있습니다. status=name-exists

  • 대시보드는 플러그인에 속합니다. plugin title status=plugin-dashboard

응답 본문에는 다음과 같은 속성이 있습니다. 다른 대시보드의 제목이 같은 경우 status 값은 입니다name-exists.

HTTP/1.1 412 Precondition Failed Content-Type: application/json; charset=UTF-8 Content-Length: 97 { "message": "The dashboard has been changed by someone else", "status": "version-mismatch" }

uid로 대시보드 가져오기

GET /api/dashboards/uid/:uid

uid와 일치하는 대시보드를 반환합니다. 반환된 메타데이터에는 대시보드가 포함된 폴더의 UID에 대한 정보가 포함될 수 있습니다.

요청 예제

GET /api/dashboards/uid/cIBgcSjkk HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

응답의 예

HTTP/1.1 200 Content-Type: application/json { "dashboard": { "id": 1, "uid": "cIBgcSjkk", "title": "Production Overview", "tags": [ "templated" ], "timezone": "browser", "schemaVersion": 16, "version": 0 }, "meta": { "isStarred": false, "url": "/d/cIBgcSjkk/production-overview", "folderId": 2, "folderUid": "l3KqBxCMz", "slug": "production-overview" //deprecated in Grafana v5.0 } }

상태 코드:

  • 200 — 찾음

  • 401 — 승인되지 않았습니다

  • 403 — 액세스가 거부되었습니다.

  • 404 — 찾을 수 없음

uid로 대시보드 삭제

DELETE /api/dashboards/uid/:uid

uid와 일치하는 대시보드를 삭제합니다.

요청 예제

DELETE /api/dashboards/uid/cIBgcSjkk HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

응답의 예

HTTP/1.1 200 Content-Type: application/json { "title": "Production Overview", "message": "Dashboard Production Overview deleted", "id": 2 }

상태 코드:

  • 200 — 삭제됨

  • 401 — 승인되지 않았습니다

  • 403 — 액세스가 거부되었습니다.

  • 404 — 찾을 수 없음

홈 대시보드를 가져옵니다.

GET /api/dashboards/home

홈 대시보드를 반환합니다.

요청 예제

GET /api/dashboards/home HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

응답의 예

HTTP/1.1 200 Content-Type: application/json { "dashboard": { "editable":false, "hideControls":true, "nav":[ { "enable":false, "type":"timepicker" } ], "style":"dark", "tags":[], "templating":{ "list":[ ] }, "time":{ }, "timezone":"browser", "title":"Home", "version":5 }, "meta": { "isHome":true, "canSave":false, "canEdit":false, "canStar":false, "url":"", "expires":"0001-01-01T00:00:00Z", "created":"0001-01-01T00:00:00Z" } }

대시보드 태그 가져오기

GET /api/dashboards/tags

대시보드의 모든 태그를 반환합니다.

요청 예제

GET /api/dashboards/tags HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

응답의 예

HTTP/1.1 200 Content-Type: application/json [ { "term":"tag1", "count":1 }, { "term":"tag2", "count":4 } ]