Fix timeshift() function with multiple targets, closes #338
This commit is contained in:
14
dist/datasource-zabbix/datasource.js
vendored
14
dist/datasource-zabbix/datasource.js
vendored
@@ -235,13 +235,6 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
|||||||
value: function query(options) {
|
value: function query(options) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
|
||||||
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
|
||||||
|
|
||||||
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
|
|
||||||
var useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
|
|
||||||
var useTrends = this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
|
|
||||||
|
|
||||||
// Get alerts for current panel
|
// Get alerts for current panel
|
||||||
if (this.alertingEnabled) {
|
if (this.alertingEnabled) {
|
||||||
this.alertQuery(options).then(function (alert) {
|
this.alertQuery(options).then(function (alert) {
|
||||||
@@ -258,6 +251,9 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
|||||||
|
|
||||||
// Create request for each target
|
// Create request for each target
|
||||||
var promises = _.map(options.targets, function (target) {
|
var promises = _.map(options.targets, function (target) {
|
||||||
|
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
||||||
|
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
||||||
|
|
||||||
// Prevent changes of original object
|
// Prevent changes of original object
|
||||||
target = _.cloneDeep(target);
|
target = _.cloneDeep(target);
|
||||||
_this.replaceTargetVariables(target, options);
|
_this.replaceTargetVariables(target, options);
|
||||||
@@ -274,6 +270,10 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
|||||||
timeTo = time_to;
|
timeTo = time_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + _this.trendsFrom) / 1000);
|
||||||
|
var useTrendsRange = Math.ceil(utils.parseInterval(_this.trendsRange) / 1000);
|
||||||
|
var useTrends = _this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
|
||||||
|
|
||||||
// Metrics or Text query mode
|
// Metrics or Text query mode
|
||||||
if (target.mode !== 1) {
|
if (target.mode !== 1) {
|
||||||
// Migrate old targets
|
// Migrate old targets
|
||||||
|
|||||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
14
dist/test/datasource-zabbix/datasource.js
vendored
14
dist/test/datasource-zabbix/datasource.js
vendored
@@ -106,13 +106,6 @@ var ZabbixAPIDatasource = function () {
|
|||||||
value: function query(options) {
|
value: function query(options) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
|
||||||
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
|
||||||
|
|
||||||
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
|
|
||||||
var useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
|
|
||||||
var useTrends = this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
|
|
||||||
|
|
||||||
// Get alerts for current panel
|
// Get alerts for current panel
|
||||||
if (this.alertingEnabled) {
|
if (this.alertingEnabled) {
|
||||||
this.alertQuery(options).then(function (alert) {
|
this.alertQuery(options).then(function (alert) {
|
||||||
@@ -129,6 +122,9 @@ var ZabbixAPIDatasource = function () {
|
|||||||
|
|
||||||
// Create request for each target
|
// Create request for each target
|
||||||
var promises = _lodash2.default.map(options.targets, function (target) {
|
var promises = _lodash2.default.map(options.targets, function (target) {
|
||||||
|
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
||||||
|
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
||||||
|
|
||||||
// Prevent changes of original object
|
// Prevent changes of original object
|
||||||
target = _lodash2.default.cloneDeep(target);
|
target = _lodash2.default.cloneDeep(target);
|
||||||
_this.replaceTargetVariables(target, options);
|
_this.replaceTargetVariables(target, options);
|
||||||
@@ -145,6 +141,10 @@ var ZabbixAPIDatasource = function () {
|
|||||||
timeTo = time_to;
|
timeTo = time_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + _this.trendsFrom) / 1000);
|
||||||
|
var useTrendsRange = Math.ceil(utils.parseInterval(_this.trendsRange) / 1000);
|
||||||
|
var useTrends = _this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
|
||||||
|
|
||||||
// Metrics or Text query mode
|
// Metrics or Text query mode
|
||||||
if (target.mode !== 1) {
|
if (target.mode !== 1) {
|
||||||
// Migrate old targets
|
// Migrate old targets
|
||||||
|
|||||||
@@ -58,16 +58,6 @@ class ZabbixAPIDatasource {
|
|||||||
* @return {Object} Grafana metrics object with timeseries data for each target.
|
* @return {Object} Grafana metrics object with timeseries data for each target.
|
||||||
*/
|
*/
|
||||||
query(options) {
|
query(options) {
|
||||||
let timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
|
||||||
let timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
|
||||||
|
|
||||||
let useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
|
|
||||||
let useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
|
|
||||||
let useTrends = this.trends && (
|
|
||||||
(timeFrom <= useTrendsFrom) ||
|
|
||||||
(timeTo - timeFrom >= useTrendsRange)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get alerts for current panel
|
// Get alerts for current panel
|
||||||
if (this.alertingEnabled) {
|
if (this.alertingEnabled) {
|
||||||
this.alertQuery(options).then(alert => {
|
this.alertQuery(options).then(alert => {
|
||||||
@@ -84,6 +74,9 @@ class ZabbixAPIDatasource {
|
|||||||
|
|
||||||
// Create request for each target
|
// Create request for each target
|
||||||
let promises = _.map(options.targets, target => {
|
let promises = _.map(options.targets, target => {
|
||||||
|
let timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
||||||
|
let timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
||||||
|
|
||||||
// Prevent changes of original object
|
// Prevent changes of original object
|
||||||
target = _.cloneDeep(target);
|
target = _.cloneDeep(target);
|
||||||
this.replaceTargetVariables(target, options);
|
this.replaceTargetVariables(target, options);
|
||||||
@@ -96,6 +89,13 @@ class ZabbixAPIDatasource {
|
|||||||
timeTo = time_to;
|
timeTo = time_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
|
||||||
|
let useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
|
||||||
|
let useTrends = this.trends && (
|
||||||
|
(timeFrom <= useTrendsFrom) ||
|
||||||
|
(timeTo - timeFrom >= useTrendsRange)
|
||||||
|
);
|
||||||
|
|
||||||
// Metrics or Text query mode
|
// Metrics or Text query mode
|
||||||
if (target.mode !== 1) {
|
if (target.mode !== 1) {
|
||||||
// Migrate old targets
|
// Migrate old targets
|
||||||
|
|||||||
Reference in New Issue
Block a user