Use Data frames response format (#1099)

* Use data frames for numeric data

* Use data frames for text data

* Use data frames for IT services

* fix multiple series

* Convert to the wide format if possible

* Fix table format for text data

* Add refId to the data frames

* Align time series from Zabbix API

* Fill gaps with nulls

* Fix moving average functions

* Option for disabling data alignment

* remove unused logging

* Add labels to data frames

* Detect units

* Set min and max for if percent unit used

* Use value mapping from Zabbix

* Rename unitConverter -> convertZabbixUnit

* More units

* Add missing points in front of each series

* Fix handling table data

* fix db connector data frames handling

* fix it services data frames handling

* Detect all known grafana units

* Chore: remove unused logging

* Fix problems format

* Debug logging: show original units

* Add global option for disabling data alignment

* Add tooltip for the disableDataAlignment feature

* Add note about query options

* Functions for aligning timeseries on the backend
This commit is contained in:
Alexander Zobnin
2020-12-22 15:33:14 +03:00
committed by GitHub
parent ad378a81e1
commit 83618178f0
18 changed files with 700 additions and 91 deletions

View File

@@ -134,6 +134,7 @@ function convertGrafanaTSResponse(time_series, items, addHostName) {
'__zbx_item': { value: item.name },
'__zbx_item_name': { value: item.name },
'__zbx_item_key': { value: item.key_ },
'__zbx_item_interval': { value: item.delay },
};
if (_.keys(hosts).length > 0) {
@@ -153,6 +154,7 @@ function convertGrafanaTSResponse(time_series, items, addHostName) {
target: alias,
datapoints,
scopedVars,
item
};
});

View File

@@ -161,11 +161,15 @@ export class ZabbixAPIConnector {
getItems(hostids, appids, itemtype) {
const params: any = {
output: [
'name', 'key_',
'name',
'key_',
'value_type',
'hostid',
'status',
'state'
'state',
'units',
'valuemapid',
'delay'
],
sortfield: 'name',
webitems: true,
@@ -651,6 +655,15 @@ export class ZabbixAPIConnector {
return this.request('script.execute', params);
}
getValueMappings() {
const params = {
output: 'extend',
selectMappings: "extend",
};
return this.request('valuemap.get', params);
}
}
function filterTriggersByAcknowledge(triggers, acknowledged) {

View File

@@ -20,17 +20,17 @@ interface AppsResponse extends Array<any> {
const REQUESTS_TO_PROXYFY = [
'getHistory', 'getTrend', 'getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs',
'getEvents', 'getAlerts', 'getHostAlerts', 'getAcknowledges', 'getITService', 'getSLA', 'getVersion', 'getProxies',
'getEventAlerts', 'getExtendedEventData', 'getProblems', 'getEventsHistory', 'getTriggersByIds', 'getScripts'
'getEventAlerts', 'getExtendedEventData', 'getProblems', 'getEventsHistory', 'getTriggersByIds', 'getScripts', 'getValueMappings'
];
const REQUESTS_TO_CACHE = [
'getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs', 'getITService', 'getProxies'
'getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs', 'getITService', 'getProxies', 'getValueMappings'
];
const REQUESTS_TO_BIND = [
'getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts',
'getAcknowledges', 'getITService', 'getVersion', 'acknowledgeEvent', 'getProxies', 'getEventAlerts',
'getExtendedEventData', 'getScripts', 'executeScript',
'getExtendedEventData', 'getScripts', 'executeScript', 'getValueMappings'
];
export class Zabbix implements ZabbixConnector {
@@ -55,6 +55,7 @@ export class Zabbix implements ZabbixConnector {
getExtendedEventData: (eventids) => Promise<any>;
getMacros: (hostids: any[]) => Promise<any>;
getVersion: () => Promise<string>;
getValueMappings: () => Promise<any>;
constructor(options) {
const {