mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: Support more than 10 series name segments when using alias patterns, Closes #1126
This commit is contained in:
parent
5a46c2397b
commit
a58330f4d8
@ -3,6 +3,7 @@
|
||||
**Enhancements**
|
||||
- [Issue #1028](https://github.com/grafana/grafana/issues/1028). Graph: New legend option ``hideEmtpy`` to hide series with only null values from legend
|
||||
- [Issue #1242](https://github.com/grafana/grafana/issues/1242). OpenTSDB: Downsample query field now supports interval template variable
|
||||
- [Issue #1126](https://github.com/grafana/grafana/issues/1126). InfluxDB: Support more than 10 series name segments when using alias ``$number`` patterns
|
||||
|
||||
**Fixes**
|
||||
- [Issue #1199](https://github.com/grafana/grafana/issues/1199). Graph: fix for series tooltip when one series is hidden/disabled
|
||||
|
@ -106,21 +106,23 @@ function (_) {
|
||||
};
|
||||
|
||||
p.createNameForSeries = function(seriesName, groupByColValue) {
|
||||
var name = this.alias
|
||||
.replace('$s', seriesName);
|
||||
|
||||
var regex = /\$(\w+)/g;
|
||||
var segments = seriesName.split('.');
|
||||
for (var i = 0; i < segments.length; i++) {
|
||||
if (segments[i].length > 0) {
|
||||
name = name.replace('$' + i, segments[i]);
|
||||
|
||||
return this.alias.replace(regex, function(match, group) {
|
||||
if (group === 's') {
|
||||
return seriesName;
|
||||
}
|
||||
}
|
||||
else if (group === 'g') {
|
||||
return groupByColValue;
|
||||
}
|
||||
var index = parseInt(group);
|
||||
if (_.isNumber(index) && index < segments.length) {
|
||||
return segments[index];
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
if (this.groupByField) {
|
||||
name = name.replace('$g', groupByColValue);
|
||||
}
|
||||
|
||||
return name;
|
||||
};
|
||||
|
||||
return InfluxSeries;
|
||||
|
@ -80,6 +80,27 @@ define([
|
||||
|
||||
});
|
||||
|
||||
describe('given an alias format and many segments', function() {
|
||||
var series = new InfluxSeries({
|
||||
seriesList: [
|
||||
{
|
||||
columns: ['time', 'mean', 'sequence_number'],
|
||||
name: 'a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12',
|
||||
points: [[1402596000, 10, 1], [1402596001, 12, 2]]
|
||||
}
|
||||
],
|
||||
alias: '$5.$11.mean'
|
||||
});
|
||||
|
||||
var result = series.getTimeSeries();
|
||||
|
||||
it('should generate correct series name', function() {
|
||||
expect(result[0].target).to.be('a5.a11.mean');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('given an alias format with group by field', function() {
|
||||
var series = new InfluxSeries({
|
||||
seriesList: [
|
||||
|
Loading…
Reference in New Issue
Block a user