Grafana Node Graph tutorial

Grafana can display graph data, for example:
Graph Example

rely

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

step

(1) Grafana adds a data source, selects Node Graph API
Node Graph API Data Source
and fills in the Node Graph API URL, such as http://localhost:9999
Node Graph API URL
Note: $URLThree APIs need to be provided

  • $URL/api/heatlhHealth check interface
    • method: GET
    • Just return HTTP CODE 200
  • $URL/api/graph/fieldsField interfaces involved in graph nodes and edges
    • 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/dataGraph node and edge relationship data interface
    • 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 creates a new Panel, selects Node Graph
Node Graph Panel
and selects the corresponding Data Source as the data source just added
Data Source - Node Graph API
(3) Gets the graph
Node Graph

reference

  • 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

Guess you like

Origin blog.csdn.net/xchenhao/article/details/131138667