From 37ff432f9db716930f9247c0c71286eac053c002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 4 Feb 2016 09:48:17 +0100 Subject: [PATCH] fix(influxdb): fix for influxdb when using format as table and having group by time, fixes #2928 --- CHANGELOG.md | 3 ++- .../app/plugins/datasource/influxdb/influx_series.js | 8 ++++++-- .../datasource/influxdb/specs/influx_series_specs.ts | 10 +++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 225e1db96ac..09e009d0c75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ * **InfluxDB**: Support for policy selection in query editor, closes [#2018](https://github.com/grafana/grafana/issues/2018) ### Breaking changes -* **Plugin API**: Both datasource and panel plugin api (and plugin.json schema) have been updated, requiring a minor update to plugins. See [plugin api](https://github.com/grafana/grafana/blob/master/public/app/plugins/plugin_api.md) for more info. +* **Plugin API**: Both datasource and panel plugin api (and plugin.json schema) have been updated, requiring an update to plugins. See [plugin api](https://github.com/grafana/grafana/blob/master/public/app/plugins/plugin_api.md) for more info. * **InfluxDB 0.8.x** The data source for the old version of influxdb (0.8.x) is no longer included in default builds, but can easily be installed via improved plugin system, closes [#3523](https://github.com/grafana/grafana/issues/3523) * **KairosDB** The data source is no longer included in default builds, but can easily be installed via improved plugin system, closes [#3524](https://github.com/grafana/grafana/issues/3524) @@ -18,6 +18,7 @@ ### Bug fixes * **Playlist**: Fix for memory leak when running a playlist, closes [#3794](https://github.com/grafana/grafana/pull/3794) +* **InfluxDB**: Fix for InfluxDB and table panel when using Format As Table and having group by time, fixes [#3928](https://github.com/grafana/grafana/pull/3928) # 2.6.1 (unrelased, 2.6.x branch) diff --git a/public/app/plugins/datasource/influxdb/influx_series.js b/public/app/plugins/datasource/influxdb/influx_series.js index 86f018ee11d..19e20390fd2 100644 --- a/public/app/plugins/datasource/influxdb/influx_series.js +++ b/public/app/plugins/datasource/influxdb/influx_series.js @@ -133,14 +133,18 @@ function (_, TableModel) { if (series.values) { for (i = 0; i < series.values.length; i++) { var values = series.values[i]; + var reordered = [values[0]]; if (series.tags) { for (var key in series.tags) { if (series.tags.hasOwnProperty(key)) { - values.splice(1, 0, series.tags[key]); + reordered.push(series.tags[key]); } } } - table.rows.push(values); + for (j = 1; j < values.length; j++) { + reordered.push(values[j]); + } + table.rows.push(reordered); } } }); diff --git a/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts b/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts index a99c1f77dc9..c60c45aa13c 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts @@ -189,9 +189,9 @@ describe('when generating timeseries from influxdb response', function() { series: [ { name: 'app.prod.server1.count', - tags: {}, - columns: ['time', 'datacenter', 'value'], - values: [[1431946625000, 'America', 10], [1431946626000, 'EU', 12]] + tags: {datacenter: 'Africa', server: 'server2'}, + columns: ['time', 'value2', 'value'], + values: [[1431946625000, 23, 10], [1431946626000, 25, 12]] } ] }; @@ -201,8 +201,8 @@ describe('when generating timeseries from influxdb response', function() { var table = series.getTable(); expect(table.type).to.be('table'); - expect(table.columns.length).to.be(3); - expect(table.rows[0]).to.eql([1431946625000, 'America', 10]); + expect(table.columns.length).to.be(5); + expect(table.rows[0]).to.eql([1431946625000, 'Africa', 'server2', 23, 10]); }); });