config updates (#1800)
* cleanup * update create plugin config and query help fix * query types file * Update docker-compose.yml Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> * addressed review comments --------- Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import React, { useEffect, FormEvent } from 'react';
|
||||
import { useAsyncFn } from 'react-use';
|
||||
import { AnnotationQuery, SelectableValue } from '@grafana/data';
|
||||
import { InlineField, InlineSwitch, Input, Select } from '@grafana/ui';
|
||||
import { ZabbixMetricsQuery } from '../types';
|
||||
import { ZabbixMetricsQuery } from '../types/query';
|
||||
import { ZabbixQueryEditorProps } from './QueryEditor';
|
||||
import { QueryEditorRow } from './QueryEditor/QueryEditorRow';
|
||||
import { MetricPicker } from '../../components';
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
Tooltip,
|
||||
useStyles2,
|
||||
} from '@grafana/ui';
|
||||
import { ZabbixAuthType, ZabbixDSOptions, ZabbixSecureJSONData } from '../types';
|
||||
import { ZabbixAuthType, ZabbixDSOptions, ZabbixSecureJSONData } from '../types/config';
|
||||
import { gte } from 'semver';
|
||||
import {
|
||||
Auth,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Button, ClickOutsideWrapper, Icon, Input, Menu, useStyles2, useTheme2 } from '@grafana/ui';
|
||||
import { FuncDef } from '../../types';
|
||||
import { FuncDef } from '../../types/query';
|
||||
import { getCategories } from '../../metricFunctions';
|
||||
|
||||
// import { mapFuncDefsToSelectables } from './helpers';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { FunctionEditorControlsProps, FunctionEditorControls } from './FunctionE
|
||||
|
||||
import { useStyles2, Tooltip } from '@grafana/ui';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { MetricFunc } from '../../types';
|
||||
import { MetricFunc } from '../../types/query';
|
||||
|
||||
interface FunctionEditorProps extends FunctionEditorControlsProps {
|
||||
func: MetricFunc;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Icon } from '@grafana/ui';
|
||||
import { MetricFunc } from '../../types';
|
||||
import { MetricFunc } from '../../types/query';
|
||||
|
||||
const DOCS_FUNC_REF_URL = 'https://grafana.com/docs/plugins/alexanderzobnin-zabbix-app/latest/reference/functions/';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { HorizontalGroup, InlineLabel, useStyles2 } from '@grafana/ui';
|
||||
import { FunctionEditor } from './FunctionEditor';
|
||||
import { EditableParam, FunctionParamEditor } from './FunctionParamEditor';
|
||||
import { mapFuncInstanceToParams } from './helpers';
|
||||
import { MetricFunc } from '../../types';
|
||||
import { MetricFunc } from '../../types/query';
|
||||
|
||||
export type FunctionEditorProps = {
|
||||
func: MetricFunc;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { MetricFunc } from '../../types';
|
||||
import { MetricFunc } from '../../types/query';
|
||||
|
||||
export type ParamDef = {
|
||||
name: string;
|
||||
|
||||
@@ -4,7 +4,8 @@ import { InlineField, Select } from '@grafana/ui';
|
||||
import * as c from '../constants';
|
||||
import { migrate, DS_QUERY_SCHEMA } from '../migrations';
|
||||
import { ZabbixDatasource } from '../datasource';
|
||||
import { ShowProblemTypes, ZabbixDSOptions, ZabbixMetricsQuery, ZabbixQueryOptions, ZabbixTagEvalType } from '../types';
|
||||
import { ShowProblemTypes, ZabbixMetricsQuery, ZabbixQueryOptions, ZabbixTagEvalType, QueryType } from '../types/query';
|
||||
import { ZabbixDSOptions } from '../types/config';
|
||||
import { MetricsQueryEditor } from './QueryEditor/MetricsQueryEditor';
|
||||
import { QueryFunctionsEditor } from './QueryEditor/QueryFunctionsEditor';
|
||||
import { QueryOptionsEditor } from './QueryEditor/QueryOptionsEditor';
|
||||
@@ -16,7 +17,7 @@ import { TriggersQueryEditor } from './QueryEditor/TriggersQueryEditor';
|
||||
import { UserMacrosQueryEditor } from './QueryEditor/UserMacrosQueryEditor';
|
||||
import { QueryEditorRow } from './QueryEditor/QueryEditorRow';
|
||||
|
||||
const zabbixQueryTypeOptions: Array<SelectableValue<string>> = [
|
||||
const zabbixQueryTypeOptions: Array<SelectableValue<QueryType>> = [
|
||||
{
|
||||
value: c.MODE_METRICS,
|
||||
label: 'Metrics',
|
||||
@@ -200,7 +201,7 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: ZabbixQ
|
||||
<>
|
||||
<QueryEditorRow>
|
||||
<InlineField label="Query type" labelWidth={12}>
|
||||
<Select
|
||||
<Select<QueryType>
|
||||
isSearchable={false}
|
||||
width={24}
|
||||
value={queryType}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { FormEvent } from 'react';
|
||||
import { InlineField, Input } from '@grafana/ui';
|
||||
import { ZabbixMetricsQuery } from '../../types';
|
||||
import { ZabbixMetricsQuery } from '../../types/query';
|
||||
import { QueryEditorRow } from './QueryEditorRow';
|
||||
|
||||
export interface Props {
|
||||
|
||||
@@ -8,7 +8,8 @@ import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { MetricPicker } from '../../../components';
|
||||
import { getVariableOptions } from './utils';
|
||||
import { ZabbixDatasource } from '../../datasource';
|
||||
import { ZabbixMetricsQuery, ZBXItem, ZBXItemTag } from '../../types';
|
||||
import { ZabbixMetricsQuery } from '../../types/query';
|
||||
import { ZBXItem, ZBXItemTag } from '../../types';
|
||||
import { itemTagToString } from '../../utils';
|
||||
|
||||
export interface Props {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { MetricPicker } from '../../../components';
|
||||
import { getVariableOptions } from './utils';
|
||||
import { ZabbixDatasource } from '../../datasource';
|
||||
import { ZabbixMetricsQuery, ZabbixTagEvalType } from '../../types';
|
||||
import { ZabbixMetricsQuery, ZabbixTagEvalType } from '../../types/query';
|
||||
|
||||
const showProblemsOptions: Array<SelectableValue<string>> = [
|
||||
{ label: 'Problems', value: 'problems' },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { swap } from '../../utils';
|
||||
import { createFuncInstance } from '../../metricFunctions';
|
||||
import { FuncDef, MetricFunc, ZabbixMetricsQuery } from '../../types';
|
||||
import { FuncDef, MetricFunc, ZabbixMetricsQuery } from '../../types/query';
|
||||
import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { InlineFormLabel } from '@grafana/ui';
|
||||
import { ZabbixFunctionEditor } from '../FunctionEditor/ZabbixFunctionEditor';
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
useStyles2,
|
||||
} from '@grafana/ui';
|
||||
import * as c from '../../constants';
|
||||
import { ZabbixQueryOptions } from '../../types';
|
||||
import { ZabbixQueryOptions } from '../../types/query';
|
||||
|
||||
const ackOptions: Array<SelectableValue<number>> = [
|
||||
{ label: 'all triggers', value: 2 },
|
||||
|
||||
@@ -8,7 +8,7 @@ import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { MetricPicker } from '../../../components';
|
||||
import { getVariableOptions } from './utils';
|
||||
import { ZabbixDatasource } from '../../datasource';
|
||||
import { ZabbixMetricsQuery } from '../../types';
|
||||
import { ZabbixMetricsQuery } from '../../types/query';
|
||||
|
||||
const slaPropertyList: Array<SelectableValue<string>> = [
|
||||
{ label: 'Status', value: 'status' },
|
||||
|
||||
@@ -8,7 +8,7 @@ import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { MetricPicker } from '../../../components';
|
||||
import { getVariableOptions } from './utils';
|
||||
import { ZabbixDatasource } from '../../datasource';
|
||||
import { ZabbixMetricsQuery } from '../../types';
|
||||
import { ZabbixMetricsQuery } from '../../types/query';
|
||||
|
||||
export interface Props {
|
||||
query: ZabbixMetricsQuery;
|
||||
|
||||
@@ -9,7 +9,8 @@ import { MetricPicker } from '../../../components';
|
||||
import { getVariableOptions } from './utils';
|
||||
import { itemTagToString } from '../../utils';
|
||||
import { ZabbixDatasource } from '../../datasource';
|
||||
import { ZabbixMetricsQuery, ZBXItem, ZBXItemTag } from '../../types';
|
||||
import { ZabbixMetricsQuery } from '../../types/query';
|
||||
import { ZBXItem, ZBXItemTag } from '../../types';
|
||||
|
||||
const countByOptions: Array<SelectableValue<string>> = [
|
||||
{ value: '', label: 'All triggers' },
|
||||
|
||||
@@ -8,7 +8,7 @@ import { QueryEditorRow } from './QueryEditorRow';
|
||||
import { MetricPicker } from '../../../components';
|
||||
import { getVariableOptions } from './utils';
|
||||
import { ZabbixDatasource } from '../../datasource';
|
||||
import { ZabbixMetricsQuery } from '../../types';
|
||||
import { ZabbixMetricsQuery } from '../../types/query';
|
||||
|
||||
export interface Props {
|
||||
query: ZabbixMetricsQuery;
|
||||
|
||||
@@ -11,7 +11,9 @@ import responseHandler from './responseHandler';
|
||||
import problemsHandler from './problemsHandler';
|
||||
import { Zabbix } from './zabbix/zabbix';
|
||||
import { ZabbixAPIError } from './zabbix/connectors/zabbix_api/zabbixAPIConnector';
|
||||
import { ProblemDTO, ShowProblemTypes, VariableQueryTypes, ZabbixDSOptions, ZabbixMetricsQuery } from './types';
|
||||
import { ProblemDTO, VariableQueryTypes } from './types';
|
||||
import { ZabbixMetricsQuery, ShowProblemTypes } from './types/query';
|
||||
import { ZabbixDSOptions } from './types/config';
|
||||
import { BackendSrvRequest, getBackendSrv, getTemplateSrv, toDataQueryResponse } from '@grafana/runtime';
|
||||
import {
|
||||
DataFrame,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import { FuncDef } from './types';
|
||||
import { FuncDef } from './types/query';
|
||||
import { isNumeric } from './utils';
|
||||
|
||||
const index = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import { ZabbixMetricsQuery } from './types';
|
||||
import { ZabbixMetricsQuery } from './types/query';
|
||||
import * as c from './constants';
|
||||
|
||||
export const DS_QUERY_SCHEMA = 12;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
},
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Alexander Zobnin",
|
||||
"url": "https://github.com/alexanderzobnin/grafana-zabbix"
|
||||
"name": "Grafana Labs",
|
||||
"url": "https://grafana.com"
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/icn-zabbix-datasource.svg",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import * as utils from './utils';
|
||||
import { DataFrame, Field, FieldType, ArrayVector, dateTime } from '@grafana/data';
|
||||
import { ZBXProblem, ZBXTrigger, ProblemDTO, ZBXEvent, ZabbixMetricsQuery } from './types';
|
||||
import { ZabbixMetricsQuery } from './types/query';
|
||||
import { ZBXProblem, ZBXTrigger, ProblemDTO, ZBXEvent } from './types';
|
||||
|
||||
export function joinTriggersWithProblems(problems: ZBXProblem[], triggers: ZBXTrigger[]): ProblemDTO[] {
|
||||
const problemDTOList: ProblemDTO[] = [];
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
#### Max data points
|
||||
|
||||
Override max data points, automatically set to graph width in pixels. Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this number. If there are more real values, then by default they will be consolidated using averages. This could hide real peaks and max values in your series. Point consolidation will affect series legend values (min,max,total,current).
|
||||
|
||||
#### Query Mode
|
||||
|
||||
##### Merics
|
||||
|
||||
Data from numeric items.
|
||||
|
||||
##### Text
|
||||
|
||||
Data from items with `Character`, `Text` or `Log` type.
|
||||
|
||||
##### IT Services
|
||||
|
||||
Time series representation of IT Services data
|
||||
|
||||
###### IT service property
|
||||
|
||||
Zabbix returns the following availability information about IT service:
|
||||
|
||||
- Status - current status of the IT service
|
||||
- SLA - SLA for the given time interval
|
||||
- OK time - time the service was in OK state, in seconds
|
||||
@@ -19,17 +27,20 @@ Zabbix returns the following availability information about IT service:
|
||||
- Down time - time the service was in scheduled downtime, in seconds
|
||||
|
||||
##### Item ID
|
||||
Data from items with specified ID's (comma separated).
|
||||
This mode is suitable for rendering charts in grafana by passing itemids as url params.
|
||||
|
||||
Data from items with specified ID's (comma separated).
|
||||
This mode is suitable for rendering charts in grafana by passing itemids as url params.
|
||||
|
||||
1. Create multivalue template variable with type _Custom_, for example, `itemids`.
|
||||
1. Create graph with desired parameters and use `$itemids` in _Item IDs_ filed.
|
||||
1. Save dashboard.
|
||||
1. Click to graph title and select _Share_ -> _Direct link rendered image_.
|
||||
1. Use this URL for graph png image and set `var-itemids` param to desired IDs. Note, for multiple IDs you should pass multiple params, like `&var-itemids=28276&var-itemids=28277`.
|
||||
2. Create graph with desired parameters and use `$itemids` in _Item IDs_ filed.
|
||||
3. Save dashboard.
|
||||
4. Click to graph title and select _Share_ -> _Direct link rendered image_.
|
||||
5. Use this URL for graph png image and set `var-itemids` param to desired IDs. Note, for multiple IDs you should pass multiple params, like `&var-itemids=28276&var-itemids=28277`.
|
||||
|
||||
##### Triggers
|
||||
|
||||
Active triggers count for selected hosts or table data like Zabbix _System status_ panel on the main dashboard.
|
||||
|
||||
#### Documentation links:
|
||||
#### Documentation links
|
||||
|
||||
[Grafana-Zabbix Documentation](https://grafana.github.io/grafana-zabbix)
|
||||
- [Grafana-Zabbix Documentation](https://grafana.com/docs/plugins/alexanderzobnin-zabbix-app/latest/)
|
||||
|
||||
@@ -16,7 +16,8 @@ import {
|
||||
TIME_SERIES_TIME_FIELD_NAME,
|
||||
TIME_SERIES_VALUE_FIELD_NAME,
|
||||
} from '@grafana/data';
|
||||
import { ZabbixMetricsQuery, ZBXGroup, ZBXTrigger } from './types';
|
||||
import { ZabbixMetricsQuery } from './types/query';
|
||||
import { ZBXGroup, ZBXTrigger } from './types';
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CoreApp, DataQueryRequest } from '@grafana/data';
|
||||
import { ZabbixMetricsQuery } from './types';
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
import { ZabbixMetricsQuery } from './types/query';
|
||||
import {
|
||||
MODE_ITEMID,
|
||||
MODE_ITSERVICE,
|
||||
|
||||
@@ -1,128 +1,4 @@
|
||||
import { BusEventWithPayload, DataQuery, DataSourceJsonData, DataSourceRef, SelectableValue } from '@grafana/data';
|
||||
|
||||
export interface ZabbixDSOptions extends DataSourceJsonData {
|
||||
authType?: ZabbixAuthType;
|
||||
username: string;
|
||||
password?: string;
|
||||
trends: boolean;
|
||||
trendsFrom: string;
|
||||
trendsRange: string;
|
||||
cacheTTL: string;
|
||||
timeout?: number;
|
||||
dbConnectionEnable: boolean;
|
||||
dbConnectionDatasourceId?: number;
|
||||
dbConnectionDatasourceName?: string;
|
||||
dbConnectionRetentionPolicy?: string;
|
||||
disableReadOnlyUsersAck: boolean;
|
||||
disableDataAlignment: boolean;
|
||||
enableSecureSocksProxy?: boolean;
|
||||
}
|
||||
|
||||
export interface ZabbixSecureJSONData {
|
||||
password?: string;
|
||||
apiToken?: string;
|
||||
}
|
||||
|
||||
export interface ZabbixConnectionInfo {
|
||||
zabbixVersion: string;
|
||||
dbConnectorStatus: {
|
||||
dsType: string;
|
||||
dsName: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ZabbixConnectionTestQuery {
|
||||
datasourceId: number;
|
||||
queryType: string;
|
||||
}
|
||||
|
||||
export interface ZabbixMetricsQuery extends DataQuery {
|
||||
schema: number;
|
||||
queryType: string;
|
||||
datasourceId: number;
|
||||
group: { filter: string; name?: string };
|
||||
host: { filter: string; name?: string };
|
||||
application: { filter: string; name?: string };
|
||||
itemTag: { filter: string; name?: string };
|
||||
item: { filter: string; name?: string };
|
||||
macro: { filter: string; macro?: string };
|
||||
textFilter: string;
|
||||
mode: number;
|
||||
itemids: string;
|
||||
useCaptureGroups: boolean;
|
||||
proxy?: { filter: string };
|
||||
trigger?: { filter: string };
|
||||
itServiceFilter?: string;
|
||||
slaFilter?: string;
|
||||
slaProperty?: any;
|
||||
slaInterval?: string;
|
||||
tags?: { filter: string };
|
||||
triggers?: { minSeverity: number; acknowledged: number; count: boolean };
|
||||
countTriggersBy?: 'problems' | 'items' | '';
|
||||
evaltype?: ZabbixTagEvalType;
|
||||
functions?: MetricFunc[];
|
||||
options?: ZabbixQueryOptions;
|
||||
// Problems
|
||||
showProblems?: ShowProblemTypes;
|
||||
// Deprecated
|
||||
hostFilter?: string;
|
||||
itemFilter?: string;
|
||||
macroFilter?: string;
|
||||
}
|
||||
|
||||
export interface ZabbixQueryOptions {
|
||||
showDisabledItems?: boolean;
|
||||
skipEmptyValues?: boolean;
|
||||
disableDataAlignment?: boolean;
|
||||
useZabbixValueMapping?: boolean;
|
||||
useTrends?: 'default' | 'true' | 'false';
|
||||
// Problems options
|
||||
minSeverity?: number;
|
||||
sortProblems?: string;
|
||||
acknowledged?: number;
|
||||
hostsInMaintenance?: boolean;
|
||||
hostProxy?: boolean;
|
||||
limit?: number;
|
||||
useTimeRange?: boolean;
|
||||
severities?: number[];
|
||||
count?: boolean;
|
||||
|
||||
// Annotations
|
||||
showOkEvents?: boolean;
|
||||
hideAcknowledged?: boolean;
|
||||
showHostname?: boolean;
|
||||
}
|
||||
|
||||
export interface MetricFunc {
|
||||
text: string;
|
||||
params: Array<string | number>;
|
||||
def: FuncDef;
|
||||
added?: boolean;
|
||||
}
|
||||
|
||||
export interface FuncDef {
|
||||
name: string;
|
||||
params: ParamDef[];
|
||||
defaultParams: Array<string | number>;
|
||||
category?: string;
|
||||
shortName?: any;
|
||||
fake?: boolean;
|
||||
version?: string;
|
||||
description?: string;
|
||||
/**
|
||||
* True if the function was not found on the list of available function descriptions.
|
||||
*/
|
||||
unknown?: boolean;
|
||||
}
|
||||
|
||||
export type ParamDef = {
|
||||
name: string;
|
||||
type: string;
|
||||
options?: Array<string | number>;
|
||||
multiple?: boolean;
|
||||
optional?: boolean;
|
||||
version?: string;
|
||||
};
|
||||
import { BusEventWithPayload, DataSourceRef, SelectableValue } from '@grafana/data';
|
||||
|
||||
// The paths of these files have moved around in Grafana and they don't resolve properly
|
||||
// either. Safer not to bother trying to import them just for type hinting.
|
||||
@@ -210,12 +86,6 @@ export enum VariableQueryTypes {
|
||||
ItemValues = 'itemValues',
|
||||
}
|
||||
|
||||
export enum ShowProblemTypes {
|
||||
Problems = 'problems',
|
||||
Recent = 'recent',
|
||||
History = 'history',
|
||||
}
|
||||
|
||||
export interface ProblemDTO {
|
||||
triggerid?: string;
|
||||
eventid?: string;
|
||||
@@ -411,13 +281,3 @@ export interface ZBXAlert {
|
||||
export class ZBXQueryUpdatedEvent extends BusEventWithPayload<any> {
|
||||
static type = 'zbx-query-updated';
|
||||
}
|
||||
|
||||
export enum ZabbixAuthType {
|
||||
UserLogin = 'userLogin',
|
||||
Token = 'token',
|
||||
}
|
||||
|
||||
export enum ZabbixTagEvalType {
|
||||
AndOr = '0',
|
||||
Or = '2',
|
||||
}
|
||||
|
||||
28
src/datasource/types/config.ts
Normal file
28
src/datasource/types/config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { DataSourceJsonData } from '@grafana/data';
|
||||
|
||||
export enum ZabbixAuthType {
|
||||
UserLogin = 'userLogin',
|
||||
Token = 'token',
|
||||
}
|
||||
|
||||
export type ZabbixDSOptions = {
|
||||
authType?: ZabbixAuthType;
|
||||
username: string;
|
||||
password?: string;
|
||||
trends: boolean;
|
||||
trendsFrom: string;
|
||||
trendsRange: string;
|
||||
cacheTTL: string;
|
||||
timeout?: number;
|
||||
dbConnectionEnable: boolean;
|
||||
dbConnectionDatasourceId?: number;
|
||||
dbConnectionDatasourceName?: string;
|
||||
dbConnectionRetentionPolicy?: string;
|
||||
disableReadOnlyUsersAck: boolean;
|
||||
disableDataAlignment: boolean;
|
||||
enableSecureSocksProxy?: boolean;
|
||||
} & DataSourceJsonData;
|
||||
|
||||
type ZabbixSecureJSONDataKeys = 'password' | 'apiToken';
|
||||
|
||||
export type ZabbixSecureJSONData = Partial<Record<ZabbixSecureJSONDataKeys, string>>;
|
||||
110
src/datasource/types/query.ts
Normal file
110
src/datasource/types/query.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import { DataQuery } from '@grafana/schema';
|
||||
import * as c from './../constants';
|
||||
|
||||
export type QueryType =
|
||||
| typeof c.MODE_METRICS
|
||||
| typeof c.MODE_ITSERVICE
|
||||
| typeof c.MODE_TEXT
|
||||
| typeof c.MODE_ITEMID
|
||||
| typeof c.MODE_TRIGGERS
|
||||
| typeof c.MODE_PROBLEMS
|
||||
| typeof c.MODE_MACROS;
|
||||
|
||||
type BaseQuery = { queryType: QueryType; datasourceId: number } & DataQuery;
|
||||
|
||||
export type ZabbixMetricsQuery = {
|
||||
schema: number;
|
||||
group: { filter: string; name?: string };
|
||||
host: { filter: string; name?: string };
|
||||
application: { filter: string; name?: string };
|
||||
itemTag: { filter: string; name?: string };
|
||||
item: { filter: string; name?: string };
|
||||
macro: { filter: string; macro?: string };
|
||||
textFilter: string;
|
||||
mode: number;
|
||||
itemids: string;
|
||||
useCaptureGroups: boolean;
|
||||
proxy?: { filter: string };
|
||||
trigger?: { filter: string };
|
||||
itServiceFilter?: string;
|
||||
slaFilter?: string;
|
||||
slaProperty?: any;
|
||||
slaInterval?: string;
|
||||
tags?: { filter: string };
|
||||
triggers?: { minSeverity: number; acknowledged: number; count: boolean };
|
||||
countTriggersBy?: 'problems' | 'items' | '';
|
||||
evaltype?: ZabbixTagEvalType;
|
||||
functions?: MetricFunc[];
|
||||
options?: ZabbixQueryOptions;
|
||||
// Problems
|
||||
showProblems?: ShowProblemTypes;
|
||||
// Deprecated
|
||||
hostFilter?: string;
|
||||
itemFilter?: string;
|
||||
macroFilter?: string;
|
||||
} & BaseQuery;
|
||||
|
||||
export interface ZabbixQueryOptions {
|
||||
showDisabledItems?: boolean;
|
||||
skipEmptyValues?: boolean;
|
||||
disableDataAlignment?: boolean;
|
||||
useZabbixValueMapping?: boolean;
|
||||
useTrends?: 'default' | 'true' | 'false';
|
||||
// Problems options
|
||||
minSeverity?: number;
|
||||
sortProblems?: string;
|
||||
acknowledged?: number;
|
||||
hostsInMaintenance?: boolean;
|
||||
hostProxy?: boolean;
|
||||
limit?: number;
|
||||
useTimeRange?: boolean;
|
||||
severities?: number[];
|
||||
count?: boolean;
|
||||
|
||||
// Annotations
|
||||
showOkEvents?: boolean;
|
||||
hideAcknowledged?: boolean;
|
||||
showHostname?: boolean;
|
||||
}
|
||||
|
||||
export interface MetricFunc {
|
||||
text: string;
|
||||
params: Array<string | number>;
|
||||
def: FuncDef;
|
||||
added?: boolean;
|
||||
}
|
||||
|
||||
export interface FuncDef {
|
||||
name: string;
|
||||
params: ParamDef[];
|
||||
defaultParams: Array<string | number>;
|
||||
category?: string;
|
||||
shortName?: any;
|
||||
fake?: boolean;
|
||||
version?: string;
|
||||
description?: string;
|
||||
/**
|
||||
* True if the function was not found on the list of available function descriptions.
|
||||
*/
|
||||
unknown?: boolean;
|
||||
}
|
||||
|
||||
export type ParamDef = {
|
||||
name: string;
|
||||
type: string;
|
||||
options?: Array<string | number>;
|
||||
multiple?: boolean;
|
||||
optional?: boolean;
|
||||
version?: string;
|
||||
};
|
||||
|
||||
export enum ShowProblemTypes {
|
||||
Problems = 'problems',
|
||||
Recent = 'recent',
|
||||
History = 'history',
|
||||
}
|
||||
|
||||
export enum ZabbixTagEvalType {
|
||||
AndOr = '0',
|
||||
Or = '2',
|
||||
}
|
||||
@@ -3,7 +3,8 @@ import semver from 'semver';
|
||||
import kbn from 'grafana/app/core/utils/kbn';
|
||||
import * as utils from '../../../utils';
|
||||
import { MIN_SLA_INTERVAL, ZBX_ACK_ACTION_ADD_MESSAGE, ZBX_ACK_ACTION_NONE } from '../../../constants';
|
||||
import { ShowProblemTypes, ZBXProblem, ZBXTrigger } from '../../../types';
|
||||
import { ShowProblemTypes } from '../../../types/query';
|
||||
import { ZBXProblem, ZBXTrigger } from '../../../types';
|
||||
import { APIExecuteScriptResponse, JSONRPCError, ZBXScript } from './types';
|
||||
import { BackendSrvRequest, getBackendSrv } from '@grafana/runtime';
|
||||
import { rangeUtil } from '@grafana/data';
|
||||
|
||||
@@ -11,7 +11,8 @@ import { SQLConnector } from './connectors/sql/sqlConnector';
|
||||
import { InfluxDBConnector } from './connectors/influxdb/influxdbConnector';
|
||||
import { ZabbixConnector } from './types';
|
||||
import { joinTriggersWithEvents, joinTriggersWithProblems } from '../problemsHandler';
|
||||
import { ProblemDTO, ZBXApp, ZBXHost, ZBXItem, ZBXItemTag, ZBXTrigger, ZabbixMetricsQuery } from '../types';
|
||||
import { ZabbixMetricsQuery } from '../types/query';
|
||||
import { ProblemDTO, ZBXApp, ZBXHost, ZBXItem, ZBXItemTag, ZBXTrigger } from '../types';
|
||||
|
||||
interface AppsResponse extends Array<any> {
|
||||
appFilterEmpty?: boolean;
|
||||
|
||||
@@ -4,7 +4,8 @@ import { DataSourceRef, dateMath, PanelProps } from '@grafana/data';
|
||||
import { getDataSourceSrv } from '@grafana/runtime';
|
||||
import { contextSrv } from 'grafana/app/core/core';
|
||||
import { ProblemsPanelOptions, RTResized } from './types';
|
||||
import { ProblemDTO, ZabbixMetricsQuery, ZBXQueryUpdatedEvent, ZBXTag } from '../datasource/types';
|
||||
import { ZabbixMetricsQuery } from '../datasource/types/query';
|
||||
import { ProblemDTO, ZBXQueryUpdatedEvent, ZBXTag } from '../datasource/types';
|
||||
import { APIExecuteScriptResponse } from '../datasource/zabbix/connectors/zabbix_api/types';
|
||||
import ProblemList from './components/Problems/Problems';
|
||||
import { AckProblemData } from './components/AckModal';
|
||||
|
||||
@@ -2,8 +2,7 @@ import React from 'react';
|
||||
import { Button } from '@grafana/ui';
|
||||
import { StandardEditorProps } from '@grafana/data';
|
||||
|
||||
type Props = StandardEditorProps<any>;
|
||||
export const ResetColumnsEditor = ({ onChange }: Props): JSX.Element => {
|
||||
export const ResetColumnsEditor = ({ onChange }: StandardEditorProps<any>) => {
|
||||
return (
|
||||
<Button variant="secondary" onClick={() => onChange([])}>
|
||||
Reset columns
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { getNextRefIdChar } from './utils';
|
||||
import { ShowProblemTypes } from '../datasource/types';
|
||||
import { ShowProblemTypes } from '../datasource/types/query';
|
||||
import { ProblemsPanelOptions } from './types';
|
||||
import { PanelModel } from '@grafana/data';
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
"type": "panel",
|
||||
"name": "Zabbix Problems",
|
||||
"id": "alexanderzobnin-zabbix-triggers-panel",
|
||||
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Alexander Zobnin",
|
||||
"url": "https://github.com/alexanderzobnin/grafana-zabbix"
|
||||
"name": "Grafana Labs",
|
||||
"url": "https://grafana.com"
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/icn-zabbix-problems-panel.svg",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { DataQuery, dateMath } from '@grafana/data';
|
||||
import { dateMath } from '@grafana/data';
|
||||
import { DataQuery } from '@grafana/schema';
|
||||
import * as utils from '../datasource/utils';
|
||||
import { ProblemDTO } from 'datasource/types';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user