From 4556f90592c172da0b39fd9eb89cdcb483e50e0f Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 20 Jan 2021 11:45:25 +0300 Subject: [PATCH] Use roundInterval from @grafana/data package, fix #1142 --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 1a67b46fe..cf1fef0db 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -6,9 +6,13 @@ import { ZBX_ACK_ACTION_NONE, ZBX_ACK_ACTION_ADD_MESSAGE, MIN_SLA_INTERVAL } fro import { ShowProblemTypes, ZBXProblem } from '../../../types'; import { JSONRPCError, ZBXScript, APIExecuteScriptResponse } from './types'; import { BackendSrvRequest, getBackendSrv } from '@grafana/runtime'; +import { rangeUtil } from '@grafana/data'; const DEFAULT_ZABBIX_VERSION = '3.0.0'; +// Backward compatibility. Since Grafana 7.2 roundInterval() func was moved to @grafana/data package +const roundInterval: (interval: number) => number = rangeUtil?.roundInterval || kbn.roundInterval || kbn.round_interval; + /** * Zabbix API Wrapper. * Creates Zabbix API instance with given parameters (url, credentials and other). @@ -680,7 +684,7 @@ function filterTriggersByAcknowledge(triggers, acknowledged) { function getSLAInterval(intervalMs) { // Too many intervals may cause significant load on the database, so decrease number of resulting points const resolutionRatio = 100; - const interval = kbn.round_interval(intervalMs * resolutionRatio) / 1000; + const interval = roundInterval(intervalMs * resolutionRatio) / 1000; return Math.max(interval, MIN_SLA_INTERVAL); }