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