Skip to content

Commit f33aeb6

Browse files
committed
Merge branch 'adrianlzt-bug/show_multiple_tags_with_influxdb'
2 parents 5ec7dea + 530e1b3 commit f33aeb6

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

public/app/plugins/datasource/influxdb/influx_series.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ function (_, TableModel) {
8181
_.each(this.series, function (series) {
8282
var titleCol = null;
8383
var timeCol = null;
84-
var tagsCol = null;
84+
var tagsCol = [];
8585
var textCol = null;
8686

8787
_.each(series.columns, function(column, index) {
8888
if (column === 'time') { timeCol = index; return; }
8989
if (column === 'sequence_number') { return; }
9090
if (!titleCol) { titleCol = index; }
9191
if (column === self.annotation.titleColumn) { titleCol = index; return; }
92-
if (column === self.annotation.tagsColumn) { tagsCol = index; return; }
92+
if (_.includes(self.annotation.tagsColumn.replace(' ', '').split(","), column)) { tagsCol.push(index); return; }
9393
if (column === self.annotation.textColumn) { textCol = index; return; }
9494
});
9595

@@ -98,7 +98,7 @@ function (_, TableModel) {
9898
annotation: self.annotation,
9999
time: + new Date(value[timeCol]),
100100
title: value[titleCol],
101-
tags: value[tagsCol],
101+
tags: tagsCol.map(function(t) { return value[t]; }),
102102
text: value[textCol]
103103
};
104104

public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
22
import InfluxSeries from '../influx_series';
33

44
describe('when generating timeseries from influxdb response', function() {
5-
65
describe('given multiple fields for series', function() {
76
var options = {
87
alias: '',
@@ -68,6 +67,7 @@ describe('when generating timeseries from influxdb response', function() {
6867

6968
});
7069
});
70+
7171
describe('given measurement with default fieldname', function() {
7272
var options = { series: [
7373
{
@@ -96,6 +96,7 @@ describe('when generating timeseries from influxdb response', function() {
9696
});
9797

9898
});
99+
99100
describe('given two series', function() {
100101
var options = {
101102
alias: '',
@@ -206,5 +207,32 @@ describe('when generating timeseries from influxdb response', function() {
206207
});
207208
});
208209

210+
describe('given annotation response', function() {
211+
var options = {
212+
alias: '',
213+
annotation: {
214+
tagsColumn: 'datacenter, source'
215+
},
216+
series: [
217+
{
218+
name: "logins.count",
219+
tags: {datacenter: 'Africa', server: 'server2'},
220+
columns: ["time", "datacenter", "hostname", "source", "value"],
221+
values: [
222+
[1481549440372, "America", "10.1.100.10", "backend", 215.7432653659507],
223+
]
224+
}
225+
]
226+
};
227+
228+
it('should multiple tags', function() {
229+
var series = new InfluxSeries(options);
230+
var annotations = series.getAnnotations();
231+
232+
expect(annotations[0].tags.length).to.be(2);
233+
expect(annotations[0].tags[0]).to.be('America');
234+
expect(annotations[0].tags[1]).to.be('backend');
235+
});
236+
});
209237
});
210238

0 commit comments

Comments
 (0)