mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' into query-editor-style
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 38 KiB |
@@ -80,6 +80,13 @@ function (_, $) {
|
||||
category: categories.Calculate,
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'stddevSeries',
|
||||
params: optionalSeriesRefArgs,
|
||||
defaultParams: [''],
|
||||
category: categories.Calculate,
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'divideSeries',
|
||||
params: optionalSeriesRefArgs,
|
||||
|
||||
@@ -6,8 +6,8 @@ There are currently two separate datasources for InfluxDB in Grafana: InfluxDB 0
|
||||
|
||||
This is the plugin for InfluxDB 0.9. It is rapidly evolving and we continue to track its API.
|
||||
|
||||
InfluxDB 0.8 is no longer maintained by InfluxDB Inc, but we provide support as a convenience to existing users. You can find it [here](https://www.grafana.net/plugins/grafana-influxdb-08-datasource).
|
||||
InfluxDB 0.8 is no longer maintained by InfluxDB Inc, but we provide support as a convenience to existing users. You can find it [here](https://grafana.net/plugins/grafana-influxdb-08-datasource).
|
||||
|
||||
Read more about InfluxDB here:
|
||||
|
||||
[http://docs.grafana.org/datasources/influxdb/](http://docs.grafana.org/datasources/influxdb/)
|
||||
[http://docs.grafana.org/datasources/influxdb/](http://docs.grafana.org/datasources/influxdb/)
|
||||
|
||||
@@ -152,7 +152,9 @@ export default class InfluxQuery {
|
||||
if (interpolate) {
|
||||
value = this.templateSrv.replace(value, this.scopedVars);
|
||||
}
|
||||
value = "'" + value.replace('\\', '\\\\') + "'";
|
||||
if (isNaN(+value)) {
|
||||
value = "'" + value.replace('\\', '\\\\') + "'";
|
||||
}
|
||||
} else if (interpolate){
|
||||
value = this.templateSrv.replace(value, this.scopedVars, 'regex');
|
||||
}
|
||||
@@ -166,6 +168,8 @@ export default class InfluxQuery {
|
||||
|
||||
if (!measurement.match('^/.*/')) {
|
||||
measurement = '"' + measurement+ '"';
|
||||
} else {
|
||||
measurement = this.templateSrv.replace(measurement, this.scopedVars, 'regex');
|
||||
}
|
||||
|
||||
if (policy !== 'default') {
|
||||
|
||||
@@ -25,8 +25,8 @@ function (_) {
|
||||
}
|
||||
}
|
||||
|
||||
// quote value unless regex
|
||||
if (operator !== '=~' && operator !== '!~') {
|
||||
// quote value unless regex or number
|
||||
if (operator !== '=~' && operator !== '!~' && isNaN(+value)) {
|
||||
value = "'" + value + "'";
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,29 @@ export default class ResponseParser {
|
||||
return [];
|
||||
}
|
||||
|
||||
var series = influxResults.series[0];
|
||||
return _.map(series.values, (value) => {
|
||||
if (_.isArray(value)) {
|
||||
if (query.toLowerCase().indexOf('show tag values') >= 0) {
|
||||
return { text: (value[1] || value[0]) };
|
||||
var influxdb11format = query.toLowerCase().indexOf('show tag values') >= 0;
|
||||
|
||||
var res = {};
|
||||
_.each(influxResults.series, serie => {
|
||||
_.each(serie.values, value => {
|
||||
if (_.isArray(value)) {
|
||||
if (influxdb11format) {
|
||||
addUnique(res, value[1] || value[0]);
|
||||
} else {
|
||||
addUnique(res, value[0]);
|
||||
}
|
||||
} else {
|
||||
return { text: value[0] };
|
||||
addUnique(res, value);
|
||||
}
|
||||
} else {
|
||||
return { text: value };
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return _.map(res, value => {
|
||||
return { text: value};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function addUnique(arr, value) {
|
||||
arr[value] = value;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ describe("influxdb response parser", () => {
|
||||
{
|
||||
"name": "hostnameTagValues",
|
||||
"columns": ["hostname"],
|
||||
"values": [ ["server1"], ["server2"] ]
|
||||
"values": [ ["server1"], ["server2"], ["server2"] ]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -54,7 +54,7 @@ describe("influxdb response parser", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("response from 0.11.0", () => {
|
||||
describe("response from 0.12.0", () => {
|
||||
var response = {
|
||||
"results": [
|
||||
{
|
||||
@@ -62,8 +62,19 @@ describe("influxdb response parser", () => {
|
||||
{
|
||||
"name": "cpu",
|
||||
"columns": [ "key", "value"],
|
||||
"values": [ [ "source", "site" ], [ "source", "api" ] ]
|
||||
}
|
||||
"values": [
|
||||
[ "source", "site" ],
|
||||
[ "source", "api" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "logins",
|
||||
"columns": [ "key", "value"],
|
||||
"values": [
|
||||
[ "source", "site" ],
|
||||
[ "source", "webapi"]
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -72,15 +83,12 @@ describe("influxdb response parser", () => {
|
||||
var result = this.parser.parse(query, response);
|
||||
|
||||
it("should get two responses", () => {
|
||||
expect(_.size(result)).to.be(2);
|
||||
expect(_.size(result)).to.be(3);
|
||||
expect(result[0].text).to.be('site');
|
||||
expect(result[1].text).to.be('api');
|
||||
expect(result[2].text).to.be('webapi');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe("SHOW FIELD response", () => {
|
||||
|
||||
Reference in New Issue
Block a user