Dashboard API

Dashboard API

Note Grafana 12 이상에서 사용할 수 있어요. 이 API는 새 Grafana API 구조를 준수해요. 더 배우려면 Grafana의 API 구조 문서를 참고해요. 이 문서는 API의 최신 버전을 포함하지 않을 수 있어요. 사용 가능한 최신 엔드포인트 목록은 Swagger의 dashboard.grafana.app/v2를 참고해요.

출처: 문서

본문

Note Grafana 12 이상에서 사용할 수 있어요. 이 API는 새 Grafana API 구조를 준수해요. 더 배우려면 Grafana의 API 구조 문서를 참고해요. 이 문서는 API의 최신 버전을 포함하지 않을 수 있어요. 사용 가능한 최신 엔드포인트 목록은 Swagger의 dashboard.grafana.app/v2를 참고해요.

요구 사항 (Requirements)

Grafana Enterprise를 실행한다면 일부 엔드포인트에 특정 권한이 필요해요. 자세한 내용은 Role-based access control permissions을 참고해요.

엔드포인트 (Endpoints)

테이블 펼치기

Method Summary URI
POST Create Dashboard /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards
PUT Update Dashboard /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid
GET Get Dashboard /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid
GET Get Dashboard (DTO format) /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid/dto
GET List Dashboards /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards
DELETE Delete Dashboard /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid

대시보드 만들기 (Create Dashboard)

POST /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards

새 대시보드를 만들어요.

  • namespace: 어떤 네임스페이스를 사용할지에 대해 더 읽으려면 API 개요를 참고해요.

필수 권한

설명은 소개의 주석을 참고해요.

테이블 펼치기

Action Scope
dashboards:create folders:*``folders:uid:*
dashboards:write dashboards:*``dashboards:uid:*``folders:*``folders:uid:*

예제 생성 요청 (Example Create Request):

http

POST /apis/dashboard.grafana.app/v1/namespaces/default/dashboards HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>

{
  "metadata": {
    "name": "gdxccn",
    "annotations": {
      "grafana.app/folder": "fef30w4jaxla8b"
    },
  },
  "spec": {
    "annotations": {
    "list": [
      {
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "enable": true,
        "hide": false,
        "iconColor": "red",
        "name": "Example annotation",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        }
      }]
    },
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 0,
    "links": [
      {
        "asDropdown": false,
        "icon": "external link",
        "includeVars": false,
        "keepTime": false,
        "tags": [],
        "targetBlank": false,
        "title": "Example Link",
        "tooltip": "",
        "type": "dashboards",
        "url": ""
      }
    ],
    "panels": [
      {
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "description": "With a description",
        "fieldConfig": {
          "defaults": {
            "color": {
              "mode": "palette-classic"
            },
            "custom": {
              "axisBorderShow": false,
              "axisCenteredZero": false,
              "axisColorMode": "text",
              "axisLabel": "",
              "axisPlacement": "auto",
              "barAlignment": 0,
              "barWidthFactor": 0.6,
              "drawStyle": "line",
              "fillOpacity": 0,
              "gradientMode": "none",
              "hideFrom": {
                "legend": false,
                "tooltip": false,
                "viz": false
              },
              "insertNulls": false,
              "lineInterpolation": "linear",
              "lineWidth": 1,
              "pointSize": 5,
              "scaleDistribution": {
                "type": "linear"
              },
              "showPoints": "auto",
              "spanNulls": false,
              "stacking": {
                "group": "A",
                "mode": "none"
              },
              "thresholdsStyle": {
                "mode": "off"
              }
            },
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green"
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            }
          },
          "overrides": []
        },
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 0,
          "y": 0
        },
        "id": 1,
        "options": {
          "legend": {
            "calcs": [],
            "displayMode": "list",
            "placement": "bottom",
            "showLegend": true
          },
          "tooltip": {
            "hideZeros": false,
            "mode": "single",
            "sort": "none"
          }
        },
        "pluginVersion": "12.0.0",
        "targets": [
          {
            "datasource": {
              "type": "datasource",
              "uid": "grafana"
            },
            "refId": "A"
          }
        ],
        "title": "Example panel",
        "type": "timeseries"
      }
    ],
    "preload": false,
    "schemaVersion": 41,
    "tags": ["example"],
    "templating": {
      "list": [
        {
          "current": {
            "text": "",
            "value": ""
          },
          "definition": "",
          "description": "example description",
          "label": "ExampleLabel",
          "name": "ExampleVariable",
          "options": [],
          "query": "",
          "refresh": 1,
          "regex": "cluster",
          "type": "query"
        }
      ]
    },
    "time": {
      "from": "now-6h",
      "to": "now"
    },
    "timepicker": {},
    "timezone": "browser",
    "title": "Example Dashboard",
    "version": 0
  }
}

JSON 본문 스키마:

  • metadata.name – Grafana 고유 식별자. 이를 제공하고 싶지 않다면 대신 metadata.generateName을 무작위 생성 uid에 원하는 접두사로 설정해요(빈 문자열일 수 없음).
  • metadata.annotations.grafana.app/folder - 선택 필드, 대시보드가 생성되어야 할 폴더의 고유 식별자.
  • spec – 대시보드 json.

Note metadata 필드의 커스텀 레이블과 주석은 일부 인스턴스에서 지원되며, 이 API가 일반 공개에 도달하면 모든 인스턴스에서 전체 지원이 계획되어 있어요. 인스턴스에서 아직 지원되지 않는다면 무시돼요.

예제 응답 (Example Response):

http

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 485

{
  "kind": "Dashboard",
  "apiVersion": "dashboard.grafana.app/v1",
  "metadata": {
    "name": "gdxccn",
    "namespace": "default",
    "uid": "Cc7fA5ffHY94NnHZyMxXvFlpFtOmkK3qkBcVZPKSPXcX",
    "resourceVersion": "1",
    "generation": 1,
    "creationTimestamp": "2025-04-24T20:35:29Z",
    "labels": {
      "grafana.app/deprecatedInternalID": "11"
    },
    "annotations": {
      "grafana.app/createdBy": "service-account:dejwtrofg77y8d",
      "grafana.app/folder": "fef30w4jaxla8b"
    },
    "managedFields": [
      {
        "manager": "curl",
        "operation": "Update",
        "apiVersion": "dashboard.grafana.app/v0alpha1",
        "time": "2025-04-24T20:35:29Z",
        "fieldsType": "FieldsV1",
        "fieldsV1": {
          "f:spec": {
            "f:annotations": {
              ".": {},
              "f:list": {}
            },
            "f:editable": {},
            "f:fiscalYearStartMonth": {},
            "f:graphTooltip": {},
            "f:links": {},
            "f:panels": {},
            "f:preload": {},
            "f:schemaVersion": {},
            "f:tags": {},
            "f:templating": {
              ".": {},
              "f:list": {}
            },
            "f:time": {
              ".": {},
              "f:from": {},
              "f:to": {}
            },
            "f:timepicker": {},
            "f:timezone": {},
            "f:title": {},
            "f:version": {}
          }
        }
      }
    ]
  },
  "spec": {
    "annotations": {
      "list": [
        {
          "datasource": {
            "type": "datasource",
            "uid": "grafana"
          },
          "enable": true,
          "hide": false,
          "iconColor": "red",
          "name": "Example annotation",
          "target": {
            "limit": 100,
            "matchAny": false,
            "tags": [],
            "type": "dashboard"
          }
        }
      ]
    },
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 0,
    "links": [
      {
        "asDropdown": false,
        "icon": "external link",
        "includeVars": false,
        "keepTime": false,
        "tags": [],
        "targetBlank": false,
        "title": "Example Link",
        "tooltip": "",
        "type": "dashboards",
        "url": ""
      }
    ],
    "panels": [
      {
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "description": "With a description",
        "fieldConfig": {
          "defaults": {
            "color": {
              "mode": "palette-classic"
            },
            "custom": {
              "axisBorderShow": false,
              "axisCenteredZero": false,
              "axisColorMode": "text",
              "axisLabel": "",
              "axisPlacement": "auto",
              "barAlignment": 0,
              "barWidthFactor": 0.6,
              "drawStyle": "line",
              "fillOpacity": 0,
              "gradientMode": "none",
              "hideFrom": {
                "legend": false,
                "tooltip": false,
                "viz": false
              },
              "insertNulls": false,
              "lineInterpolation": "linear",
              "lineWidth": 1,
              "pointSize": 5,
              "scaleDistribution": {
                "type": "linear"
              },
              "showPoints": "auto",
              "spanNulls": false,
              "stacking": {
                "group": "A",
                "mode": "none"
              },
              "thresholdsStyle": {
                "mode": "off"
              }
            },
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green"
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            }
          },
          "overrides": []
        },
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 0,
          "y": 0
        },
        "id": 1,
        "options": {
          "legend": {
            "calcs": [],
            "displayMode": "list",
            "placement": "bottom",
            "showLegend": true
          },
          "tooltip": {
            "hideZeros": false,
            "mode": "single",
            "sort": "none"
          }
        },
        "pluginVersion": "12.0.0",
        "targets": [
          {
            "datasource": {
              "type": "datasource",
              "uid": "grafana"
            },
            "refId": "A"
          }
        ],
        "title": "Example panel",
        "type": "timeseries"
      }
    ],
    "preload": false,
    "schemaVersion": 41,
    "tags": [
      "example"
    ],
    "templating": {
      "list": [
        {
          "current": {
            "text": "",
            "value": ""
          },
          "definition": "",
          "description": "example description",
          "label": "ExampleLabel",
          "name": "ExampleVariable",
          "options": [],
          "query": "",
          "refresh": 1,
          "regex": "cluster",
          "type": "query"
        }
      ]
    },
    "time": {
      "from": "now-6h",
      "to": "now"
    },
    "timepicker": {},
    "timezone": "browser",
    "title": "Example Dashboard"
  },
  "status": {}

상태 코드:

  • 201 – Created
  • 400 – Errors (invalid json, missing or invalid fields, etc)
  • 401 – Unauthorized
  • 403 – Access denied
  • 409 – Conflict (dashboard with the same uid already exists)

대시보드 업데이트 (Update Dashboard)

PUT /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid

대시보드 uid를 통해 기존 대시보드를 업데이트해요.

  • namespace: 어떤 네임스페이스를 사용할지에 대해 더 읽으려면 API 개요를 참고해요.
  • uid: 업데이트할 대시보드의 고유 식별자. 대시보드 응답에서 name이 될 거예요.

필수 권한

설명은 소개의 주석을 참고해요.

테이블 펼치기

Action Scope
dashboards:write dashboards:*``dashboards:uid:*``folders:*``folders:uid:*

예제 업데이트 요청 (Example Update Request):

http

POST /apis/dashboard.grafana.app/v1/namespaces/default/dashboards/gdxccn HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>

{
  "metadata": {
    "name": "gdxccn",
    "annotations": {
      "grafana.app/folder": "fef30w4jaxla8b",
      "grafana.app/message": "commit message"
    },
  },
  "spec": {
    "title": "New dashboard - updated",
    "schemaVersion": 41,
    ...
  }
}

JSON 본문 스키마:

  • metadata.name – 고유 식별자.
  • metadata.annotations.grafana.app/folder - 선택 필드, 대시보드가 생성되어야 할 폴더의 고유 식별자.
  • metadata.annotations.grafana.app/message - 선택 필드, 버전 기록용 커밋 메시지를 설정하려면.
  • spec – 대시보드 json.

Note metadata 필드의 커스텀 레이블과 주석은 일부 인스턴스에서 지원되며, 이 API가 일반 공개에 도달하면 모든 인스턴스에서 전체 지원이 계획되어 있어요. 인스턴스에서 아직 지원되지 않는다면 무시돼요.

예제 응답 (Example Response):

http

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 485

{
  "kind": "Dashboard",
  "apiVersion": "dashboard.grafana.app/v1",
  "metadata": {
    "name": "gdxccn",
    "namespace": "default",
    "uid": "Cc7fA5ffHY94NnHZyMxXvFlpFtOmkK3qkBcVZPKSPXcX",
    "resourceVersion": "2",
    "generation": 2,
    "creationTimestamp": "2025-03-06T19:57:18Z",
    "annotations": {
      "grafana.app/folder": "fef30w4jaxla8b",
      "grafana.app/createdBy": "service-account:cef2t2rfm73lsb",
      "grafana.app/updatedBy": "service-account:cef2t2rfm73lsb",
      "grafana.app/updatedTimestamp": "2025-03-07T02:58:36Z"
    }
  },
  "spec": {
    "schemaVersion": 41,
    "title": "New dashboard - updated",
    ...
  }
}

상태 코드:

  • 200 – OK
  • 400 – Errors (invalid json, missing or invalid fields, etc)
  • 401 – Unauthorized
  • 403 – Access denied
  • 409 – Conflict (dashboard with the same version already exists)

대시보드 가져오기 (Get Dashboard)

GET /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid

대시보드 uid를 통해 대시보드를 가져와요.

  • namespace: 어떤 네임스페이스를 사용할지에 대해 더 읽으려면 API 개요를 참고해요.
  • uid: 업데이트할 대시보드의 고유 식별자. 대시보드 응답에서 name이 될 거예요.

필수 권한

설명은 소개의 주석을 참고해요.

테이블 펼치기

Action Scope
dashboards:read dashboards:*``dashboards:uid:*``folders:*``folders:uid:*

예제 가져오기 요청 (Example Get Request):

http

GET /apis/dashboard.grafana.app/v1/namespaces/default/dashboards/gdxccn HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>

예제 응답 (Example Response):

http

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 485

{
  "kind": "Dashboard",
  "apiVersion": "dashboard.grafana.app/v1",
  "metadata": {
    "name": "gdxccn",
    "namespace": "default",
    "uid": "Cc7fA5ffHY94NnHZyMxXvFlpFtOmkK3qkBcVZPKSPXcX",
    "resourceVersion": "2",
    "generation": 2,
    "creationTimestamp": "2025-03-06T19:57:18Z",
    "annotations": {
      "grafana.app/createdBy": "service-account:cef2t2rfm73lsb",
      "grafana.app/updatedBy": "service-account:cef2t2rfm73lsb",
      "grafana.app/updatedTimestamp": "2025-03-07T02:58:36Z"
    }
  },
  "spec": {
    "schemaVersion": 41,
    "title": "New dashboard - updated",
    ...
  }
}

상태 코드:

  • 200 – OK
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not Found

추가 접근 정보 검색 (Retrieve additional access information)

GET /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid/dto

추가 접근 정보와 함께 대시보드를 검색해요.

GET 응답에는 공개 대시보드인지, 아니면 요청한 사용자의 대시보드 권한(admin, editor)인지 같은 데이터가 있는 추가 access 섹션이 포함돼요.

대시보드 나열 (List Dashboards)

GET /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards

주어진 조직의 모든 대시보드를 나열해요. limit 쿼리 매개변수로 반환되는 최대 대시보드 수를 제어할 수 있어요. 그런 다음 반환된 continue 토큰을 사용해 다음 대시보드 페이지를 가져올 수 있어요.

  • namespace: 어떤 네임스페이스를 사용할지에 대해 더 읽으려면 API 개요를 참고해요.

쿼리 매개변수:

  • limit (선택): 반환할 최대 대시보드 수
  • continue (선택): 다음 페이지를 가져오기 위한 이전 응답의 continue 토큰

필수 권한

설명은 소개의 주석을 참고해요.

테이블 펼치기

Action Scope
dashboards:read dashboards:*``dashboards:uid:*``folders:*``folders:uid:*

예제 가져오기 요청 (Example Get Request):

http

GET /apis/dashboard.grafana.app/v1/namespaces/default/dashboards?limit=1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>

예제 응답 (Example Response):

http

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 644

{
  "kind": "DashboardList",
  "apiVersion": "dashboard.grafana.app/v1alpha1",
  "metadata": {
    "resourceVersion": "1741315830000",
    "continue": "eyJvIj...NlfQ=="
  },
  "items": [
    {
      "kind": "Dashboard",
      "apiVersion": "dashboard.grafana.app/v1alpha1",
      "metadata": {
        "name": "gpqcmf",
        "namespace": "default",
        "uid": "VQyL7pNTpfGPNlPM6HRJSePrBg5dXmxr4iPQL7txLtwX",
        "resourceVersion": "1",
        "generation": 1,
        "creationTimestamp": "2025-03-06T19:50:30Z",
        "annotations": {
          "grafana.app/createdBy": "service-account:cef2t2rfm73lsb",
          "grafana.app/updatedBy": "service-account:cef2t2rfm73lsb",
          "grafana.app/updatedTimestamp": "2025-03-06T19:50:30Z"
        }
      },
      "spec": {
        "schemaVersion": 41,
        "title": "New dashboard",
        "uid": "gpqcmf",
        "version": 1,
        ...
      }
    }
  ]
}

metadata.continue 필드에는 다음 페이지를 가져오기 위한 토큰이 들어 있어요.

continue 토큰을 사용한 후속 요청의 예 (Example subsequent request using continue token):

http

GET /apis/dashboard.grafana.app/v1/namespaces/default/dashboards?limit=1&continue=eyJvIj...NlfQ== HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>

예제 후속 응답 (Example subsequent response):

http

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8

{
  "kind": "DashboardList",
  "apiVersion": "dashboard.grafana.app/v1alpha1",
  "items": [
    {
      "kind": "Dashboard",
      "apiVersion": "dashboard.grafana.app/v1alpha1",
      "metadata": {
        "name": "hpqcmg",
        "namespace": "default",
        "uid": "WQyL7pNTpfGPNlPM6HRJSePrBg5dXmxr4iPQL7txLtwY",
        "resourceVersion": "1",
        "generation": 1,
        "creationTimestamp": "2025-03-06T19:51:31Z",
        "annotations": {
          "grafana.app/createdBy": "service-account:cef2t2rfm73lsb",
          "grafana.app/updatedBy": "service-account:cef2t2rfm73lsb",
          "grafana.app/updatedTimestamp": "2025-03-06T19:51:31Z"
        }
      },
      "spec": {
        "schemaVersion": 41,
        "title": "Another dashboard",
        "uid": "hpqcmg",
        "version": 1,
        ...
      }
    }
  ]
}

metadata에 continue 필드가 없는 응답을 받아 마지막 페이지에 도달했음을 나타낼 때까지 업데이트된 continue 토큰으로 요청을 계속해요.

상태 코드:

  • 200 – OK
  • 401 – Unauthorized
  • 403 – Access denied

대시보드 기록 나열 (List dashboard history)

특정 쿼리 매개변수와 함께 List 엔드포인트를 사용해 대시보드의 전체 버전 기록을 검색할 수 있어요. 세부 사항과 예제는 Resource history HTTP API를 참고해요.

대시보드 삭제 (Delete Dashboard)

DELETE /apis/dashboard.grafana.app/v1/namespaces/:namespace/dashboards/:uid

대시보드 uid를 통해 대시보드를 삭제해요.

  • namespace: 어떤 네임스페이스를 사용할지에 대해 더 읽으려면 API 개요를 참고해요.
  • uid: 업데이트할 대시보드의 고유 식별자. 대시보드 응답의 metadata.name 필드이며 metadata.uid 필드가 아니에요.

필수 권한

설명은 소개의 주석을 참고해요.

테이블 펼치기

Action Scope
dashboards:delete dashboards:*``dashboards:uid:*``folders:*``folders:uid:*

예제 삭제 요청 (Example Delete Request):

http

DELETE /apis/dashboard.grafana.app/v1/namespaces/default/dashboards/gdxccn HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer <SERVI...KEN>

예제 응답 (Example Response):

http

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 78

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Success",
  "details": {
    "name": "gdxccn",
    "group": "dashboard.grafana.app",
    "kind": "dashboards",
    "uid": "Cc7fA5ffHY94NnHZyMxXvFlpFtOmkK3qkBcVZPKSPXcX"
  }
}

상태 코드:

  • 200 – OK
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found

더 알아보기 (Learn more)