Filter problems by time range, fix #1094
This commit is contained in:
@@ -453,7 +453,7 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
|
||||
});
|
||||
}
|
||||
|
||||
queryProblems(target, timeRange, options) {
|
||||
queryProblems(target: ZabbixMetricsQuery, timeRange, options) {
|
||||
const [timeFrom, timeTo] = timeRange;
|
||||
const userIsEditor = contextSrv.isEditor || contextSrv.isGrafanaAdmin;
|
||||
|
||||
@@ -512,7 +512,7 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
|
||||
}
|
||||
|
||||
let getProblemsPromise: Promise<ProblemDTO[]>;
|
||||
if (showProblems === ShowProblemTypes.History) {
|
||||
if (showProblems === ShowProblemTypes.History || target.options?.useTimeRange) {
|
||||
problemsOptions.timeFrom = timeFrom;
|
||||
problemsOptions.timeTo = timeTo;
|
||||
getProblemsPromise = this.zabbix.getProblemsHistory(groupFilter, hostFilter, appFilter, proxyFilter, problemsOptions);
|
||||
|
||||
@@ -334,6 +334,12 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Use time range"
|
||||
checked="ctrl.target.options.useTimeRange"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Hosts in maintenance"
|
||||
|
||||
@@ -101,6 +101,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
queryOptionsText: string;
|
||||
metric: any;
|
||||
showQueryOptions: boolean;
|
||||
oldTarget: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, $rootScope, $sce, templateSrv) {
|
||||
@@ -370,9 +371,6 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
this.targetChanged();
|
||||
}
|
||||
}
|
||||
oldTarget(oldTarget: any, target: any) {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
onVariableChange() {
|
||||
if (this.isContainsVariables()) {
|
||||
@@ -405,7 +403,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
targetChanged() {
|
||||
this.initFilters();
|
||||
this.parseTarget();
|
||||
this.panelCtrl.refresh();
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
addFunction(funcDef) {
|
||||
@@ -466,6 +464,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
hostsInMaintenance: "Show hosts in maintenance",
|
||||
limit: "Limit problems",
|
||||
hostProxy: "Show proxy",
|
||||
useTimeRange: "Use time range",
|
||||
};
|
||||
|
||||
let optionsMap = {};
|
||||
|
||||
@@ -51,6 +51,8 @@ export interface ZabbixMetricsQuery extends DataQuery {
|
||||
tags?: { filter: string; };
|
||||
functions: ZabbixMetricFunction[];
|
||||
options: ZabbixQueryOptions;
|
||||
// Problems
|
||||
showProblems?: ShowProblemTypes;
|
||||
// Deprecated
|
||||
hostFilter?: string;
|
||||
itemFilter?: string;
|
||||
@@ -67,6 +69,8 @@ export interface ZabbixQueryOptions {
|
||||
hostsInMaintenance?: boolean;
|
||||
hostProxy?: boolean;
|
||||
limit?: number;
|
||||
useTimeRange?: boolean;
|
||||
severities?: number[];
|
||||
}
|
||||
|
||||
export interface ZabbixMetricFunction {
|
||||
|
||||
Reference in New Issue
Block a user