Problems: Able to select tags evaluation type, fixes #1600
This commit is contained in:
@@ -4,7 +4,7 @@ import { InlineField, InlineFieldRow, Select } from '@grafana/ui';
|
|||||||
import * as c from '../constants';
|
import * as c from '../constants';
|
||||||
import { migrate, DS_QUERY_SCHEMA } from '../migrations';
|
import { migrate, DS_QUERY_SCHEMA } from '../migrations';
|
||||||
import { ZabbixDatasource } from '../datasource';
|
import { ZabbixDatasource } from '../datasource';
|
||||||
import { ShowProblemTypes, ZabbixDSOptions, ZabbixMetricsQuery, ZabbixQueryOptions } from '../types';
|
import { ShowProblemTypes, ZabbixDSOptions, ZabbixMetricsQuery, ZabbixQueryOptions, ZabbixTagEvalType } from '../types';
|
||||||
import { MetricsQueryEditor } from './QueryEditor/MetricsQueryEditor';
|
import { MetricsQueryEditor } from './QueryEditor/MetricsQueryEditor';
|
||||||
import { QueryFunctionsEditor } from './QueryEditor/QueryFunctionsEditor';
|
import { QueryFunctionsEditor } from './QueryEditor/QueryFunctionsEditor';
|
||||||
import { QueryOptionsEditor } from './QueryEditor/QueryOptionsEditor';
|
import { QueryOptionsEditor } from './QueryEditor/QueryOptionsEditor';
|
||||||
@@ -68,6 +68,7 @@ const getDefaultQuery: () => Partial<ZabbixMetricsQuery> = () => ({
|
|||||||
tags: { filter: '' },
|
tags: { filter: '' },
|
||||||
proxy: { filter: '' },
|
proxy: { filter: '' },
|
||||||
textFilter: '',
|
textFilter: '',
|
||||||
|
evaltype: ZabbixTagEvalType.AndOr,
|
||||||
options: {
|
options: {
|
||||||
showDisabledItems: false,
|
showDisabledItems: false,
|
||||||
skipEmptyValues: false,
|
skipEmptyValues: false,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { QueryEditorRow } from './QueryEditorRow';
|
|||||||
import { MetricPicker } from '../../../components';
|
import { MetricPicker } from '../../../components';
|
||||||
import { getVariableOptions } from './utils';
|
import { getVariableOptions } from './utils';
|
||||||
import { ZabbixDatasource } from '../../datasource';
|
import { ZabbixDatasource } from '../../datasource';
|
||||||
import { ZabbixMetricsQuery } from '../../types';
|
import { ZabbixMetricsQuery, ZabbixTagEvalType } from '../../types';
|
||||||
|
|
||||||
const showProblemsOptions: Array<SelectableValue<string>> = [
|
const showProblemsOptions: Array<SelectableValue<string>> = [
|
||||||
{ label: 'Problems', value: 'problems' },
|
{ label: 'Problems', value: 'problems' },
|
||||||
@@ -25,6 +25,11 @@ const severityOptions: Array<SelectableValue<number>> = [
|
|||||||
{ value: 5, label: 'Disaster' },
|
{ value: 5, label: 'Disaster' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const evaltypeOptions: Array<SelectableValue<ZabbixTagEvalType>> = [
|
||||||
|
{ label: 'AND/OR', value: ZabbixTagEvalType.AndOr },
|
||||||
|
{ label: 'OR', value: ZabbixTagEvalType.Or },
|
||||||
|
];
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
query: ZabbixMetricsQuery;
|
query: ZabbixMetricsQuery;
|
||||||
datasource: ZabbixDatasource;
|
datasource: ZabbixDatasource;
|
||||||
@@ -206,6 +211,15 @@ export const ProblemsQueryEditor = ({ query, datasource, onChange }: Props) => {
|
|||||||
onBlur={onTextFilterChange('tags')}
|
onBlur={onTextFilterChange('tags')}
|
||||||
/>
|
/>
|
||||||
</InlineField>
|
</InlineField>
|
||||||
|
<InlineField>
|
||||||
|
<Select
|
||||||
|
isSearchable={false}
|
||||||
|
width={15}
|
||||||
|
value={query.evaltype}
|
||||||
|
options={evaltypeOptions}
|
||||||
|
onChange={onPropChange('evaltype')}
|
||||||
|
/>
|
||||||
|
</InlineField>
|
||||||
</QueryEditorRow>
|
</QueryEditorRow>
|
||||||
<QueryEditorRow>
|
<QueryEditorRow>
|
||||||
<InlineField label="Show" labelWidth={12}>
|
<InlineField label="Show" labelWidth={12}>
|
||||||
|
|||||||
@@ -675,6 +675,10 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
|
|||||||
problemsOptions.tags = tags;
|
problemsOptions.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target?.evaltype) {
|
||||||
|
problemsOptions.evaltype = target?.evaltype;
|
||||||
|
}
|
||||||
|
|
||||||
if (target.options?.acknowledged === 0 || target.options?.acknowledged === 1) {
|
if (target.options?.acknowledged === 0 || target.options?.acknowledged === 1) {
|
||||||
problemsOptions.acknowledged = !!target.options?.acknowledged;
|
problemsOptions.acknowledged = !!target.options?.acknowledged;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export interface ZabbixMetricsQuery extends DataQuery {
|
|||||||
tags?: { filter: string };
|
tags?: { filter: string };
|
||||||
triggers?: { minSeverity: number; acknowledged: number; count: boolean };
|
triggers?: { minSeverity: number; acknowledged: number; count: boolean };
|
||||||
countTriggersBy?: 'problems' | 'items' | '';
|
countTriggersBy?: 'problems' | 'items' | '';
|
||||||
|
evaltype?: ZabbixTagEvalType;
|
||||||
functions?: MetricFunc[];
|
functions?: MetricFunc[];
|
||||||
options?: ZabbixQueryOptions;
|
options?: ZabbixQueryOptions;
|
||||||
// Problems
|
// Problems
|
||||||
@@ -415,3 +416,8 @@ export enum ZabbixAuthType {
|
|||||||
UserLogin = 'userLogin',
|
UserLogin = 'userLogin',
|
||||||
Token = 'token',
|
Token = 'token',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ZabbixTagEvalType {
|
||||||
|
AndOr = '0',
|
||||||
|
Or = '2',
|
||||||
|
}
|
||||||
|
|||||||
@@ -481,7 +481,7 @@ export class ZabbixAPIConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getProblems(groupids, hostids, applicationids, options): Promise<ZBXProblem[]> {
|
getProblems(groupids, hostids, applicationids, options): Promise<ZBXProblem[]> {
|
||||||
const { timeFrom, timeTo, recent, severities, limit, acknowledged, tags } = options;
|
const { timeFrom, timeTo, recent, severities, limit, acknowledged, tags, evaltype } = options;
|
||||||
|
|
||||||
const params: any = {
|
const params: any = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
@@ -492,7 +492,7 @@ export class ZabbixAPIConnector {
|
|||||||
object: '0',
|
object: '0',
|
||||||
sortfield: ['eventid'],
|
sortfield: ['eventid'],
|
||||||
sortorder: 'DESC',
|
sortorder: 'DESC',
|
||||||
evaltype: '2',
|
evaltype: '0',
|
||||||
// preservekeys: '1',
|
// preservekeys: '1',
|
||||||
groupids,
|
groupids,
|
||||||
hostids,
|
hostids,
|
||||||
@@ -512,6 +512,10 @@ export class ZabbixAPIConnector {
|
|||||||
params.tags = tags;
|
params.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (evaltype) {
|
||||||
|
params.evaltype = evaltype;
|
||||||
|
}
|
||||||
|
|
||||||
if (limit) {
|
if (limit) {
|
||||||
params.limit = limit;
|
params.limit = limit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user