0

I am using grafana dashboard version Grafana v8.1.3 (a61f38238c) . I am trying to save a dashboard with apanel. When i try to save dashboard ,i have the following error.

db query error: Error 1054: Unknown column 'time' in 'field list'

{
  "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": []
    }
  ]
}

Is there any special string escaping needed ? The error is while saving the dash board.

1 Answers1

0

In mysql Time is a reserved word so try change columname

 "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",
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107