TDengine的tdengine-datasource数据显示不全问题

TDengine有 tdengine-datasource可以配合pull和grafana进行系统监控。在使用TDengine2.4以上版本时,数据显示不全,可以通过对脚本的修改来完善。

1、 tdengine-datasource安装

安装步骤参考:https://github.com/taosdata/grafanaplugin,步骤很详细,按步骤安装即可。安装后的grafana dashboard id 是15146。

在TDengine集群中,显示界面如下:

2、“No data”问题修正

可以看到有几处显示为“No data”。这时可以通过修改脚本来修正,步骤如下:

2.1、下拉"Number of MNodes",选Inspect

选Json,替换Json内容,点“Applay”确定

此处的JSON脚本为:

{
  "id": 27,
  "gridPos": {
    "h": 3,
    "w": 3,
    "x": 2,
    "y": 7
  },
  "type": "stat",
  "title": "Number of MNodes",
  "repeatDirection": "h",
  "transformations": [
    {
      "id": "filterByValue",
      "options": {
        "filters": [
          {
            "config": {
              "id": "greater",
              "options": {
                "value": 0
              }
            },
            "fieldName": "dnodes"
          }
        ],
        "match": "any",
        "type": "include"
      }
    },
    {
      "id": "reduce",
      "options": {
        "includeTimeField": false,
        "mode": "reduceFields",
        "reducers": [
          "count"
        ]
      }
    },
    {
      "id": "filterFieldsByName",
      "options": {
        "include": {
          "names": [
            "dnodes"
          ]
        }
      }
    }
  ],
  "datasource": {
    "type": "tdengine-datasource",
    "uid": "lF_2I2o7k"
  },
  "pluginVersion": "8.3.2",
  "fieldConfig": {
    "defaults": {
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "red",
            "value": 80
          }
        ]
      },
      "mappings": [],
      "color": {
        "mode": "thresholds"
      }
    },
    "overrides": []
  },
  "options": {
    "reduceOptions": {
      "values": true,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "area",
    "justifyMode": "auto",
    "text": {}
  },
  "targets": [
    {
      "alias": "dnodes",
      "formatType": "Time series",
      "queryType": "SQL",
      "refId": "A",
      "sql": "show mnodes",
      "target": "select metric",
      "timeshift": {},
      "type": "timeserie"
    }
  ]
}

 2.2、替换“Number of Databases”的JSON,内容如下

{
  "id": 65,
  "gridPos": {
    "h": 3,
    "w": 3,
    "x": 9,
    "y": 7
  },
  "type": "stat",
  "title": "Number of Databases",
  "repeatDirection": "h",
  "transformations": [
    {
      "id": "reduce",
      "options": {
        "includeTimeField": false,
        "mode": "reduceFields",
        "reducers": [
          "count"
        ]
      }
    },
    {
      "id": "filterFieldsByName",
      "options": {
        "include": {
          "names": [
            "dnodes"
          ]
        }
      }
    }
  ],
  "pluginVersion": "8.3.2",
  "description": "",
  "fieldConfig": {
    "defaults": {
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "red",
            "value": 80
          }
        ]
      },
      "mappings": [],
      "color": {
        "mode": "thresholds"
      }
    },
    "overrides": []
  },
  "options": {
    "reduceOptions": {
      "values": true,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "area",
    "justifyMode": "auto",
    "text": {}
  },
  "targets": [
    {
      "alias": "dnodes",
      "colNameFormatStr": "",
      "colNameToGroup": "",
      "datasource": {
        "type": "tdengine-datasource",
        "uid": "lF_2I2o7k"
      },
      "formatType": "Time series",
      "queryType": "SQL",
      "refId": "A",
      "sql": "show databases;",
      "target": "select metric",
      "timeshift": {},
      "type": "timeserie"
    }
  ],
  "datasource": null
}

 2.3、替换“Number of Databases”的JSON,内容如下 

{
  "id": 55,
  "gridPos": {
    "h": 3,
    "w": 3,
    "x": 9,
    "y": 10
  },
  "type": "stat",
  "title": "Number of Connections",
  "repeatDirection": "h",
  "transformations": [
    {
      "id": "filterByValue",
      "options": {
        "filters": [],
        "match": "all",
        "type": "include"
      }
    },
    {
      "id": "reduce",
      "options": {
        "includeTimeField": false,
        "mode": "reduceFields",
        "reducers": [
          "count"
        ]
      }
    },
    {
      "id": "filterFieldsByName",
      "options": {
        "include": {
          "names": [
            "connId"
          ]
        }
      }
    }
  ],
  "pluginVersion": "8.3.2",
  "fieldConfig": {
    "defaults": {
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "red",
            "value": 80
          }
        ]
      },
      "mappings": [],
      "color": {
        "mode": "thresholds"
      }
    },
    "overrides": []
  },
  "options": {
    "reduceOptions": {
      "values": true,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "area",
    "justifyMode": "auto",
    "text": {}
  },
  "targets": [
    {
      "alias": "connId",
      "colNameFormatStr": "",
      "colNameToGroup": "",
      "datasource": {
        "type": "tdengine-datasource",
        "uid": "lF_2I2o7k"
      },
      "formatType": "Time series",
      "queryType": "SQL",
      "refId": "A",
      "sql": "show connections",
      "target": "select metric",
      "timeshift": {},
      "type": "timeserie"
    }
  ],
  "datasource": null
}

再次刷新,数据显示正常(参考如下),保存即可。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值