Commit ebcf2c3f by Torkel Ödegaard

InfluxDB: Support for sub second resolution graphs, Closes #714, #728, #752

parent 54fafb3a
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
- [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc - [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc
- [Issue #917](https://github.com/grafana/grafana/issues/917). OpenTSDB: Templating support for OpenTSDB series name and tags, thx @mchataigner - [Issue #917](https://github.com/grafana/grafana/issues/917). OpenTSDB: Templating support for OpenTSDB series name and tags, thx @mchataigner
**InfluxDB**
- [Issue #714](https://github.com/grafana/grafana/issues/714). InfluxDB: Support for sub second resolution graphs
**Fixes** **Fixes**
- [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other) - [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other)
- [Issue #505](https://github.com/grafana/grafana/issues/505). Graph: fix for second y axis tick unit labels wrapping on the next line - [Issue #505](https://github.com/grafana/grafana/issues/505). Graph: fix for second y axis tick unit labels wrapping on the next line
......
...@@ -99,11 +99,11 @@ function (_, kbn) { ...@@ -99,11 +99,11 @@ function (_, kbn) {
this.stats.min = currentValue; this.stats.min = currentValue;
} }
result.push([currentTime * 1000, currentValue]); result.push([currentTime, currentValue]);
} }
if (this.datapoints.length >= 2) { if (this.datapoints.length >= 2) {
this.stats.timeStep = (this.datapoints[1][1] - this.datapoints[0][1]) * 1000; this.stats.timeStep = this.datapoints[1][1] - this.datapoints[0][1];
} }
if (this.stats.max === Number.MIN_VALUE) { this.stats.max = null; } if (this.stats.max === Number.MIN_VALUE) { this.stats.max = null; }
......
...@@ -189,7 +189,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { ...@@ -189,7 +189,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
}); });
if (datapoints && datapoints.length > 0) { if (datapoints && datapoints.length > 0) {
var last = moment.utc(datapoints[datapoints.length - 1][1] * 1000); var last = moment.utc(datapoints[datapoints.length - 1][1]);
var from = moment.utc($scope.range.from); var from = moment.utc($scope.range.from);
if (last - from < -10000) { if (last - from < -10000) {
$scope.datapointsOutside = true; $scope.datapointsOutside = true;
......
...@@ -53,13 +53,24 @@ function (angular, _, $, config, kbn, moment) { ...@@ -53,13 +53,24 @@ function (angular, _, $, config, kbn, moment) {
httpOptions.headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; httpOptions.headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
} }
return this.doGraphiteRequest(httpOptions); return this.doGraphiteRequest(httpOptions).then(this.convertDataPointsToMs);
} }
catch(err) { catch(err) {
return $q.reject(err); return $q.reject(err);
} }
}; };
GraphiteDatasource.prototype.convertDataPointsToMs = function(result) {
if (!result || !result.data) { return []; }
for (var i = 0; i < result.data.length; i++) {
var series = result.data[i];
for (var y = 0; y < series.datapoints.length; y++) {
series.datapoints[y][1] *= 1000;
}
}
return result;
};
GraphiteDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) { GraphiteDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) {
// Graphite metric as annotation // Graphite metric as annotation
if (annotation.target) { if (annotation.target) {
......
...@@ -146,7 +146,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { ...@@ -146,7 +146,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
InfluxDatasource.prototype._seriesQuery = function(query) { InfluxDatasource.prototype._seriesQuery = function(query) {
return this._influxRequest('GET', '/series', { return this._influxRequest('GET', '/series', {
q: query, q: query,
time_precision: 's',
}); });
}; };
......
...@@ -100,7 +100,7 @@ function (angular, _, kbn) { ...@@ -100,7 +100,7 @@ function (angular, _, kbn) {
// TSDB returns datapoints has a hash of ts => value. // TSDB returns datapoints has a hash of ts => value.
// Can't use _.pairs(invert()) because it stringifies keys/values // Can't use _.pairs(invert()) because it stringifies keys/values
_.each(md.dps, function (v, k) { _.each(md.dps, function (v, k) {
dps.push([v, k]); dps.push([v, k * 1000]);
}); });
return { target: metricLabel, datapoints: dps }; return { target: metricLabel, datapoints: dps };
......
...@@ -136,7 +136,7 @@ define([ ...@@ -136,7 +136,7 @@ define([
}); });
it('should set barWidth', function() { it('should set barWidth', function() {
expect(ctx.plotOptions.series.bars.barWidth).to.be(10000/1.5); expect(ctx.plotOptions.series.bars.barWidth).to.be(10/1.5);
}); });
}); });
......
...@@ -21,7 +21,7 @@ define([ ...@@ -21,7 +21,7 @@ define([
maxDataPoints: 500, maxDataPoints: 500,
}; };
var response = [{ target: 'prod1.count', points: [[10, 1], [12,1]], }]; var response = [{ target: 'prod1.count', datapoints: [[10, 1], [12,1]], }];
var results; var results;
var request; var request;
......
...@@ -17,7 +17,7 @@ define([ ...@@ -17,7 +17,7 @@ define([
describe('When querying influxdb with one target using query editor target spec', function() { describe('When querying influxdb with one target using query editor target spec', function() {
var results; var results;
var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22"+ var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22"+
"+where+time+%3E+now()+-+1h+group+by+time(1s)+order+asc&time_precision=s"; "+where+time+%3E+now()+-+1h+group+by+time(1s)+order+asc";
var query = { var query = {
range: { from: 'now-1h', to: 'now' }, range: { from: 'now-1h', to: 'now' },
targets: [{ series: 'test', column: 'value', function: 'mean' }], targets: [{ series: 'test', column: 'value', function: 'mean' }],
...@@ -50,7 +50,7 @@ define([ ...@@ -50,7 +50,7 @@ define([
describe('When querying influxdb with one raw query', function() { describe('When querying influxdb with one raw query', function() {
var results; var results;
var urlExpected = "/series?p=mupp&q=select+value+from+series"+ var urlExpected = "/series?p=mupp&q=select+value+from+series"+
"+where+time+%3E+now()+-+1h&time_precision=s"; "+where+time+%3E+now()+-+1h";
var query = { var query = {
range: { from: 'now-1h', to: 'now' }, range: { from: 'now-1h', to: 'now' },
targets: [{ query: "select value from series where $timeFilter", rawQuery: true }] targets: [{ query: "select value from series where $timeFilter", rawQuery: true }]
...@@ -73,7 +73,7 @@ define([ ...@@ -73,7 +73,7 @@ define([
describe('When issuing annotation query', function() { describe('When issuing annotation query', function() {
var results; var results;
var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+ var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+
"+where+time+%3E+now()+-+1h&time_precision=s"; "+where+time+%3E+now()+-+1h";
var range = { from: 'now-1h', to: 'now' }; var range = { from: 'now-1h', to: 'now' };
var annotation = { query: 'select title from events.$server where $timeFilter' }; var annotation = { query: 'select title from events.$server where $timeFilter' };
......
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