Option for using zabbix mapping, closes #1128
This commit is contained in:
@@ -288,6 +288,11 @@
|
||||
checked="ctrl.target.options.showDisabledItems"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Use Zabbix value mapping"
|
||||
checked="ctrl.target.options.useZabbixValueMapping"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Disable data alignment"
|
||||
checked="ctrl.target.options.disableDataAlignment"
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as c from './constants';
|
||||
import * as utils from './utils';
|
||||
import * as metricFunctions from './metricFunctions';
|
||||
import * as migrations from './migrations';
|
||||
import { ShowProblemTypes } from './types';
|
||||
import { ShowProblemTypes, ZabbixMetricsQuery } from './types';
|
||||
import { CURRENT_SCHEMA_VERSION } from '../panel-triggers/migrations';
|
||||
import { getTemplateSrv, TemplateSrv } from '@grafana/runtime';
|
||||
|
||||
@@ -29,6 +29,7 @@ function getTargetDefaults() {
|
||||
showDisabledItems: false,
|
||||
skipEmptyValues: false,
|
||||
disableDataAlignment: false,
|
||||
useZabbixValueMapping: false,
|
||||
},
|
||||
table: {
|
||||
'skipEmptyValues': false
|
||||
@@ -456,6 +457,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
const metricOptionsMap = {
|
||||
showDisabledItems: "Show disabled items",
|
||||
disableDataAlignment: "Disable data alignment",
|
||||
useZabbixValueMapping: "Use Zabbix value mapping",
|
||||
};
|
||||
|
||||
const problemsOptionsMap = {
|
||||
|
||||
@@ -2,7 +2,8 @@ import _ from 'lodash';
|
||||
import TableModel from 'grafana/app/core/table_model';
|
||||
import * as c from './constants';
|
||||
import * as utils from './utils';
|
||||
import { ArrayVector, DataFrame, DataQuery, Field, FieldType, MutableDataFrame, TIME_SERIES_TIME_FIELD_NAME, TIME_SERIES_VALUE_FIELD_NAME } from '@grafana/data';
|
||||
import { ArrayVector, DataFrame, Field, FieldType, MutableDataFrame, TIME_SERIES_TIME_FIELD_NAME, TIME_SERIES_VALUE_FIELD_NAME } from '@grafana/data';
|
||||
import { ZabbixMetricsQuery } from './types';
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
@@ -60,7 +61,8 @@ function convertHistory(history, items, addHostName, convertPointCallback) {
|
||||
});
|
||||
}
|
||||
|
||||
export function seriesToDataFrame(timeseries, target: DataQuery, valueMappings?: any[], fieldType?: FieldType): DataFrame {
|
||||
export function seriesToDataFrame(timeseries, target: ZabbixMetricsQuery, valueMappings?: any[], fieldType?: FieldType): DataFrame {
|
||||
console.log(target);
|
||||
const { datapoints, scopedVars, target: seriesName, item } = timeseries;
|
||||
|
||||
const timeFiled: Field = {
|
||||
@@ -122,8 +124,8 @@ export function seriesToDataFrame(timeseries, target: DataQuery, valueMappings?:
|
||||
|
||||
// Try to use value mapping from Zabbix
|
||||
const mappings = utils.getValueMapping(item, valueMappings);
|
||||
if (mappings) {
|
||||
console.log(`Datasource: value mapping detected`);
|
||||
if (mappings && target.options?.useZabbixValueMapping) {
|
||||
console.log(`Datasource: using Zabbix value mapping`);
|
||||
valueFiled.config.mappings = mappings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ export interface ZabbixMetricsQuery extends DataQuery {
|
||||
triggers: { minSeverity: string; acknowledged: boolean; count: number; };
|
||||
queryType: string;
|
||||
datasourceId: number;
|
||||
group: { filter: string; name: string; };
|
||||
host: { filter: string; name: string; };
|
||||
application: { filter: string; name: string; };
|
||||
item: { filter: string; name: string; };
|
||||
group: { filter: string; name?: string; };
|
||||
host: { filter: string; name?: string; };
|
||||
application: { filter: string; name?: string; };
|
||||
item: { filter: string; name?: string; };
|
||||
textFilter: string;
|
||||
mode: number;
|
||||
itemids: number[];
|
||||
@@ -62,6 +62,7 @@ export interface ZabbixQueryOptions {
|
||||
showDisabledItems?: boolean;
|
||||
skipEmptyValues?: boolean;
|
||||
disableDataAlignment?: boolean;
|
||||
useZabbixValueMapping?: boolean;
|
||||
// Problems options
|
||||
minSeverity?: number;
|
||||
sortProblems?: string;
|
||||
|
||||
Reference in New Issue
Block a user