Grafana Node Graph 使用教程

Grafana 可以显示图数据,例:
Grafana Node Graph 使用教程_第1张图片

依赖

  • Grafana >= 7.5.0
    下载地址 https://grafana.com/grafana/download
# 启动 Grafana
$ ./grafana-sever
  • Grafana Node Graph API Plugin
# 安装插件
$ grafana-cli plugins install hamedkarbasi93-nodegraphapi-datasource
# 重新启动 Grafana
$ grafana-server

步骤

(1)Grafana 添加数据源,选择 Node Graph API
Node Graph API Data Source
填写 Node Graph API URL,如 http://localhost:9999
Grafana Node Graph 使用教程_第2张图片
注:$URL 需要提供三个 API

  • $URL/api/heatlh 健康检查接口
    • method: GET
    • 返回 HTTP CODE 200 即可
  • $URL/api/graph/fields 图节点与边涉及的字段接口
    • method: GET
    • content type: application/json
    • response body example:
      {
        "edges_fields": [
          {
            "field_name": "id",
            "type": "string"
          },
          {
            "field_name": "source",
            "type": "string"
          },
          {
            "field_name": "target",
            "type": "string"
          },
          {
            "field_name": "mainStat",
            "type": "number"
          }
        ],
        "nodes_fields": [
          {
            "field_name": "id",
            "type": "string"
          },
          {
            "field_name": "title",
            "type": "string"
          },
          {
            "field_name": "mainStat",
            "type": "string"
          },
          {
            "field_name": "secondaryStat",
            "type": "number"
          },
          {
            "color": "red",
            "field_name": "arc__failed",
            "type": "number"
          },
          {
            "color": "green",
            "field_name": "arc__passed",
            "type": "number"
          },
          {
            "displayName": "Role",
            "field_name": "detail__role",
            "type": "string"
          }
        ]
      }
      
  • $URL/api/graph/data 图节点与与边关系数据接口
    • method: GET
    • content type: application/json
    • response body example:
      {
          "edges": [
              {
                  "id": "1",
                  "mainStat": "53/s",
                  "source": "1",
                  "target": "2"
              }
          ],
          "nodes": [
              {
                  "arc__failed": 0.7,
                  "arc__passed": 0.3,
                  "detail__zone": "load",
                  "id": "1",
                  "subTitle": "instance:#2",
                  "title": "Service1"
              },
              {
                  "arc__failed": 0.5,
                  "arc__passed": 0.5,
                  "detail__zone": "transform",
                  "id": "2",
                  "subTitle": "instance:#3",
                  "title": "Service2"
              }
          ]
      }
      

(2)Grafana 新建 Panel,选择 Node Graph
Node Graph Panel
选择对应的 Data Source 为刚刚添加的数据源
Grafana Node Graph 使用教程_第3张图片
(3)得到图
Grafana Node Graph 使用教程_第4张图片

参考

  • https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/node-graph/ Grafana Node Graph Panel
  • https://grafana.com/grafana/plugins/hamedkarbasi93-nodegraphapi-datasource/ Grafana Node Graph API

你可能感兴趣的:(数据,grafana,graph,node,图,Graph)