Grafana 未知列问题
Posted
技术标签:
【中文标题】Grafana 未知列问题【英文标题】:Grafana unknown column issue 【发布时间】:2021-11-15 16:42:40 【问题描述】:我正在使用 grafana 仪表板版本 Grafana v8.1.3 (a61f38238c) 。我正在尝试使用 apanel 保存仪表板。当我尝试保存仪表板时,出现以下错误。
db 查询错误:错误 1054:“字段列表”中的“时间”列未知
"id": 2,
"gridPos":
"h": 8,
"w": 12,
"x": 0,
"y": 0
,
"type": "gauge",
"title": "Panel Title",
"datasource": "mysql-test",
"pluginVersion": "8.1.3",
"fieldConfig":
"defaults":
"thresholds":
"mode": "absolute",
"steps": [
"color": "green",
"value": null
,
"color": "red",
"value": 80
]
,
"mappings": [],
"color":
"mode": "thresholds"
,
"overrides": []
,
"options":
"reduceOptions":
"values": false,
"calcs": [
"lastNotNull"
],
"fields": ""
,
"showThresholdLabels": false,
"showThresholdMarkers": true,
"text":
,
"targets": [
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": false,
"rawSql": "SELECT \r\n NOW() AS \"time\", \r\n name AS metric, \r\n salary as value \r\nFROM demosales \r\nORDER BY empid\r\n",
"refId": "A",
"select": [
[
"params": [
"empid"
],
"type": "column"
]
],
"table": "demosales",
"timeColumn": "time",
"where": []
]
是否需要任何特殊的字符串转义?错误是在保存仪表板时。
【问题讨论】:
【参考方案1】:在 mysql 中Time
是保留字所以尝试更改列名
"SELECT \r\n NOW() AS \"mytime\", \r\n name AS metric, \r\n salary as value \r\nFROM demosales \r\nORDER BY empid\r\n",
【讨论】:
以上是关于Grafana 未知列问题的主要内容,如果未能解决你的问题,请参考以下文章
Grafana:使用字符串类型的 MySQL 表列作为图形的 X 轴