grafana / influxdb-flux-datasource

Grafana datasource plugin for Flux (InfluxDB)
Apache License 2.0
51 stars 21 forks source link

Time Series not working with value as String #83

Closed NotoriousBIT closed 4 years ago

NotoriousBIT commented 4 years ago

In response_parser.ts the value is parsed with parseValue().

export function getTimeSeriesFromResult(result: string) {
  const { data } = parseCSV(result);
  ...
      const datapoints = series.map(record => [parseValue(record['_value']), parseTime(getTimeRec(record))]);
  ...
}

The problem is, parseValue() only allows Numbers. So if the value is a String, it returns null.

To solve this problem parseValueWithType() should be used instead.

export function getTimeSeriesFromResult(result: string) {
  const { data, types } = parseCSV(result);
  ...
      const datapoints = series.map(record => [parseValueWithType(record['_value'], types['_value']), parseTime(getTimeRec(record))]);
  ...
}