diff --git a/src/datasource-zabbix/datasource.js b/src/datasource-zabbix/datasource.js index adbc9d63c..27387f64c 100644 --- a/src/datasource-zabbix/datasource.js +++ b/src/datasource-zabbix/datasource.js @@ -108,6 +108,9 @@ export class ZabbixDatasource { // Prevent changes of original object let target = _.cloneDeep(t); + + // Migrate old targets + target = migrations.migrate(target); this.replaceTargetVariables(target, options); // Apply Time-related functions (timeShift(), etc) @@ -123,9 +126,6 @@ export class ZabbixDatasource { // Metrics or Text query mode if (!target.mode || target.mode === c.MODE_METRICS || target.mode === c.MODE_TEXT) { - // Migrate old targets - target = migrations.migrate(target); - // Don't request undefined targets if (!target.group || !target.host || !target.item) { return []; @@ -534,6 +534,7 @@ export class ZabbixDatasource { let enabled_targets = filterEnabledTargets(options.targets); let getPanelItems = _.map(enabled_targets, t => { let target = _.cloneDeep(t); + target = migrations.migrate(target); this.replaceTargetVariables(target, options); return this.zabbix.getItemsFromTarget(target, {itemtype: 'num'}); }); diff --git a/src/datasource-zabbix/migrations.js b/src/datasource-zabbix/migrations.ts similarity index 90% rename from src/datasource-zabbix/migrations.js rename to src/datasource-zabbix/migrations.ts index 8b7502529..790e0447e 100644 --- a/src/datasource-zabbix/migrations.js +++ b/src/datasource-zabbix/migrations.ts @@ -27,11 +27,18 @@ export function migrateFrom2To3version(target) { export function migrate(target) { target.resultFormat = target.resultFormat || 'time_series'; + target = fixTargetGroup(target); if (isGrafana2target(target)) { return migrateFrom2To3version(target); - } else { - return target; } + return target; +} + +function fixTargetGroup(target) { + if (target.group && Array.isArray(target.group)) { + target.group = { 'filter': "" }; + } + return target; } function convertToRegex(str) {