From ed62822d442569e7ba287ff63d83a069a596c458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 9 Apr 2016 11:00:35 -0400 Subject: [PATCH] feat(influxdb): changed multi query encoding in order to support InfluxDB >v0.11, closes #4533 --- CHANGELOG.md | 3 +++ .../app/plugins/datasource/influxdb/datasource.ts | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2399eda7140..4c8790751af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 3.0.0-beta3 (unreleased) +### Enhancements +* **InfluxDB**: Changed multi query encoding to work with InfluxDB 0.11 & 0.12, closes [#4533](https://github.com/grafana/grafana/issues/4533) + ### Bug fixes * **Postgres**: Fixed page render crash when using postgres, fixes [#4558](https://github.com/grafana/grafana/issues/4558) * **Table panel**: Fixed table panel bug when trying to show annotations in table panel, fixes [#4563](https://github.com/grafana/grafana/issues/4563) diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index daa6ada3420..f63716e5dd6 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -55,7 +55,7 @@ export default class InfluxDatasource { query = query.replace(/\$interval/g, (target.interval || options.interval)); return query; - }).join("\n"); + }).join(";"); // replace grafana variables allQueries = allQueries.replace(/\$timeFilter/g, timeFilter); @@ -133,6 +133,17 @@ export default class InfluxDatasource { return this._influxRequest('GET', '/query', {q: query, epoch: 'ms'}); } + + serializeParams(params) { + if (!params) { return '';} + + return _.reduce(params, (memo, value, key) => { + if (value === null || value === undefined) { return memo; } + memo.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + return memo; + }, []).join("&"); + } + testDatasource() { return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(() => { return { status: "success", message: "Data source is working", title: "Success" }; @@ -166,6 +177,7 @@ export default class InfluxDatasource { data: data, precision: "ms", inspect: { type: 'influxdb' }, + paramSerializer: this.serializeParams, }; options.headers = options.headers || {};