Commit 6c93dc6a by Torkel Ödegaard

Some changes to influxdb alias pattern expansions, removed as it was to…

Some changes to influxdb alias pattern expansions, removed  as it was to confusion, added help text to influxdb metric editor view, need to polish a litle more, #525
parent 1dbbfbbb
...@@ -153,5 +153,18 @@ ...@@ -153,5 +153,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="pull-left" style="margin-top: 30px;">
<div class="span6">
<span>
<i class="icon-question-sign"></i> alias patterns:
<ul>
<li>$s = seriesName</li>
<li>$g = group by value</li>
<li>$[0-9] part of series name for series names seperated by dots.</li>
<ul>
</span>
</div>
</div>
</div> </div>
<div ng-include src="datasource.editorSrc"></div> <div ng-include src="datasource.editorSrc"></div>
<div class="editor-row" style="margin-top: 20px"> <div class="editor-row" style="margin-top: 30px">
<button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add query</button> <button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add query</button>
<div class="btn-group pull-right" style="margin-right: 10px;"> <div class="btn-group pull-right" style="margin-right: 10px;">
......
...@@ -52,10 +52,10 @@ function (_) { ...@@ -52,10 +52,10 @@ function (_) {
datapoints[i] = [metricValue, groupPoints[i][timeCol]]; datapoints[i] = [metricValue, groupPoints[i][timeCol]];
} }
seriesName = series.name + '.' + key; seriesName = series.name;
if (self.alias) { if (self.alias) {
seriesName = self.createNameForSeries(series.name, series.columns[valueCol], key); seriesName = self.createNameForSeries(series.name, key);
} }
output.push({ target: seriesName, datapoints: datapoints }); output.push({ target: seriesName, datapoints: datapoints });
...@@ -65,10 +65,9 @@ function (_) { ...@@ -65,10 +65,9 @@ function (_) {
return output; return output;
}; };
p.createNameForSeries = function(seriesName, columnName, groupByColValue) { p.createNameForSeries = function(seriesName, groupByColValue) {
var name = this.alias var name = this.alias
.replace('$s', seriesName) .replace('$s', seriesName);
.replace('$c', columnName);
var segments = seriesName.split('.'); var segments = seriesName.split('.');
for (var i = 0; i < segments.length; i++) { for (var i = 0; i < segments.length; i++) {
......
...@@ -25,13 +25,13 @@ define([ ...@@ -25,13 +25,13 @@ define([
it('should generate two time series', function() { it('should generate two time series', function() {
expect(result.length).to.be(2); expect(result.length).to.be(2);
expect(result[0].target).to.be('prod.server1.cpu.mean'); expect(result[0].target).to.be('prod.server1.cpu');
expect(result[0].datapoints[0][0]).to.be(10); expect(result[0].datapoints[0][0]).to.be(10);
expect(result[0].datapoints[0][1]).to.be(1402596000); expect(result[0].datapoints[0][1]).to.be(1402596000);
expect(result[0].datapoints[1][0]).to.be(12); expect(result[0].datapoints[1][0]).to.be(12);
expect(result[0].datapoints[1][1]).to.be(1402596001); expect(result[0].datapoints[1][1]).to.be(1402596001);
expect(result[1].target).to.be('prod.server2.cpu.mean'); expect(result[1].target).to.be('prod.server2.cpu');
expect(result[1].datapoints[0][0]).to.be(15); expect(result[1].datapoints[0][0]).to.be(15);
expect(result[1].datapoints[0][1]).to.be(1402596000); expect(result[1].datapoints[0][1]).to.be(1402596000);
expect(result[1].datapoints[1][0]).to.be(16); expect(result[1].datapoints[1][0]).to.be(16);
...@@ -49,13 +49,13 @@ define([ ...@@ -49,13 +49,13 @@ define([
points: [[1402596000, 10, 1], [1402596001, 12, 2]] points: [[1402596000, 10, 1], [1402596001, 12, 2]]
} }
], ],
alias: '$s.$c' alias: '$s.testing'
}); });
var result = series.getTimeSeries(); var result = series.getTimeSeries();
it('should generate correct series name', function() { it('should generate correct series name', function() {
expect(result[0].target).to.be('prod.server1.cpu.mean'); expect(result[0].target).to.be('prod.server1.cpu.testing');
}); });
}); });
...@@ -69,13 +69,13 @@ define([ ...@@ -69,13 +69,13 @@ define([
points: [[1402596000, 10, 1], [1402596001, 12, 2]] points: [[1402596000, 10, 1], [1402596001, 12, 2]]
} }
], ],
alias: '$1' alias: '$1.mean'
}); });
var result = series.getTimeSeries(); var result = series.getTimeSeries();
it('should generate correct series name', function() { it('should generate correct series name', function() {
expect(result[0].target).to.be('server1'); expect(result[0].target).to.be('server1.mean');
}); });
}); });
...@@ -122,13 +122,13 @@ define([ ...@@ -122,13 +122,13 @@ define([
it('should generate two time series', function() { it('should generate two time series', function() {
expect(result.length).to.be(2); expect(result.length).to.be(2);
expect(result[0].target).to.be('prod.cpu.A'); expect(result[0].target).to.be('prod.cpu');
expect(result[0].datapoints[0][0]).to.be(10); expect(result[0].datapoints[0][0]).to.be(10);
expect(result[0].datapoints[0][1]).to.be(1402596000); expect(result[0].datapoints[0][1]).to.be(1402596000);
expect(result[0].datapoints[1][0]).to.be(11); expect(result[0].datapoints[1][0]).to.be(11);
expect(result[0].datapoints[1][1]).to.be(1402596001); expect(result[0].datapoints[1][1]).to.be(1402596001);
expect(result[1].target).to.be('prod.cpu.B'); expect(result[1].target).to.be('prod.cpu');
expect(result[1].datapoints[0][0]).to.be(5); expect(result[1].datapoints[0][0]).to.be(5);
expect(result[1].datapoints[0][1]).to.be(1402596000); expect(result[1].datapoints[0][1]).to.be(1402596000);
expect(result[1].datapoints[1][0]).to.be(6); expect(result[1].datapoints[1][0]).to.be(6);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment