From ead451a97987e49b417ff57944f7d70ef4f6d5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 4 Sep 2015 07:40:28 +0200 Subject: [PATCH] feat(influxdb): More alias options, can now use syntax to reference part of a measurement name (seperated by dots), closes #2599 --- CHANGELOG.md | 3 ++- .../datasource/influxdb/influxSeries.js | 3 +++ .../influxdb/partials/query.options.html | 1 + public/test/specs/influxSeries-specs.js | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0a3ff0104d..13e2bc817f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ it allows you to add queries of differnet data source types & instances to the s - [Issue #2577](https://github.com/grafana/grafana/issues/2577). Panel: Resize handles in panel bottom right corners for easy width and height change - [Issue #2457](https://github.com/grafana/grafana/issues/2457). Admin: admin page for all grafana organizations (list / edit view) - [Issue #1186](https://github.com/grafana/grafana/issues/1186). Time Picker: New option `today`, will set time range from midnight to now +- [Issue #1186](https://github.com/grafana/grafana/issues/1186). Time Picker: New option `today`, will set time range from midnight to now **Fixes** - [Issue #2413](https://github.com/grafana/grafana/issues/2413). InfluxDB 0.9: Fix for handling empty series object in response from influxdb @@ -25,7 +26,7 @@ it allows you to add queries of differnet data source types & instances to the s - [Issue #2564](https://github.com/grafana/grafana/issues/2564). Templating: Another atempt at fixing #2534 (Init multi value template var used in repeat panel from url) - [Issue #2620](https://github.com/grafana/grafana/issues/2620). Graph: multi series tooltip did no highlight correct point when stacking was enabled and series were of different resolution - [Issue #2636](https://github.com/grafana/grafana/issues/2636). InfluxDB: Do no show template vars in dropdown for tag keys and group by keys -- [Issue #2651](https://github.com/grafana/grafana/issues/2651). InfluxDB: Fixed issue when using the eye to disable queries in the query editor and when applying aliases +- [Issue #2599](https://github.com/grafana/grafana/issues/2599). InfluxDB: More alias options, can now use `$[0-9]` syntax to reference part of a measurement name (seperated by dots) **Breaking Changes** - Notice to makers/users of custom data sources, there is a minor breaking change in 2.2 that diff --git a/public/app/plugins/datasource/influxdb/influxSeries.js b/public/app/plugins/datasource/influxdb/influxSeries.js index 62ee43b5448..67a704fab2b 100644 --- a/public/app/plugins/datasource/influxdb/influxSeries.js +++ b/public/app/plugins/datasource/influxdb/influxSeries.js @@ -56,12 +56,15 @@ function (_) { p._getSeriesName = function(series, index) { var regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g; + var segments = series.name.split('.'); return this.alias.replace(regex, function(match, g1, g2) { var group = g1 || g2; + var segIndex = parseInt(group, 10) if (group === 'm' || group === 'measurement') { return series.name; } if (group === 'col') { return series.columns[index]; } + if (!isNaN(segIndex)) { return segments[segIndex]; } if (group.indexOf('tag_') !== 0) { return match; } var tag = group.replace('tag_', ''); diff --git a/public/app/plugins/datasource/influxdb/partials/query.options.html b/public/app/plugins/datasource/influxdb/partials/query.options.html index c794e0b5323..8715b57791e 100644 --- a/public/app/plugins/datasource/influxdb/partials/query.options.html +++ b/public/app/plugins/datasource/influxdb/partials/query.options.html @@ -51,6 +51,7 @@