【问题标题】:Grafana unknown column issueGrafana 未知列问题
【发布时间】: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": []
    }
  ]
}

是否需要任何特殊的字符串转义?错误是在保存仪表板时。

【问题讨论】:

    标签: mysql grafana grafana-variable


    【解决方案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",
    

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 2021-08-17
      • 2023-02-15
      • 1970-01-01
      • 2015-07-05
      • 2013-02-24
      • 2019-01-22
      相关资源
      最近更新 更多