|
@@ -89,7 +89,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
|
|
var intervalFactor = target.intervalFactor || 1;
|
|
var intervalFactor = target.intervalFactor || 1;
|
|
|
target.step = query.step = this.calculateInterval(interval, intervalFactor);
|
|
target.step = query.step = this.calculateInterval(interval, intervalFactor);
|
|
|
var range = Math.ceil(end - start);
|
|
var range = Math.ceil(end - start);
|
|
|
- target.step = query.step = this.adjustStep(query.step, range);
|
|
|
|
|
|
|
+ target.step = query.step = this.adjustStep(query.step, this.intervalSeconds(options.interval), range);
|
|
|
queries.push(query);
|
|
queries.push(query);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -122,13 +122,13 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- this.adjustStep = function(step, range) {
|
|
|
|
|
|
|
+ this.adjustStep = function(step, autoStep, range) {
|
|
|
// Prometheus drop query if range/step > 11000
|
|
// Prometheus drop query if range/step > 11000
|
|
|
// calibrate step if it is too big
|
|
// calibrate step if it is too big
|
|
|
if (step !== 0 && range / step > 11000) {
|
|
if (step !== 0 && range / step > 11000) {
|
|
|
return Math.ceil(range / 11000);
|
|
return Math.ceil(range / 11000);
|
|
|
}
|
|
}
|
|
|
- return step;
|
|
|
|
|
|
|
+ return Math.max(step, autoStep);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.performTimeSeriesQuery = function(query, start, end) {
|
|
this.performTimeSeriesQuery = function(query, start, end) {
|
|
@@ -189,7 +189,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
|
|
var end = this.getPrometheusTime(options.range.to, true);
|
|
var end = this.getPrometheusTime(options.range.to, true);
|
|
|
var query = {
|
|
var query = {
|
|
|
expr: interpolated,
|
|
expr: interpolated,
|
|
|
- step: this.adjustStep(kbn.interval_to_seconds(step), Math.ceil(end - start)) + 's'
|
|
|
|
|
|
|
+ step: this.adjustStep(kbn.interval_to_seconds(step), 0, Math.ceil(end - start)) + 's'
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var self = this;
|
|
var self = this;
|
|
@@ -229,6 +229,10 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.calculateInterval = function(interval, intervalFactor) {
|
|
this.calculateInterval = function(interval, intervalFactor) {
|
|
|
|
|
+ return Math.ceil(this.intervalSeconds(interval) * intervalFactor);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ this.intervalSeconds = function(interval) {
|
|
|
var m = interval.match(durationSplitRegexp);
|
|
var m = interval.match(durationSplitRegexp);
|
|
|
var dur = moment.duration(parseInt(m[1]), m[2]);
|
|
var dur = moment.duration(parseInt(m[1]), m[2]);
|
|
|
var sec = dur.asSeconds();
|
|
var sec = dur.asSeconds();
|
|
@@ -236,7 +240,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
|
|
sec = 1;
|
|
sec = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return Math.ceil(sec * intervalFactor);
|
|
|
|
|
|
|
+ return sec;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.transformMetricData = function(md, options, start, end) {
|
|
this.transformMetricData = function(md, options, start, end) {
|