Skip to content

Commit b824fa1

Browse files
authored
Merge pull request grafana#6538 from grafana/alertlist_only_from_dashboard
feat(alertlist): make it possible to filter on alerts from current da…
2 parents a51de8e + abb8f33 commit b824fa1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

public/app/plugins/panel/alertlist/editor.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ <h5 class="section-heading">Options</h5>
1111
<span class="gf-form-label width-8">Max items</span>
1212
<input type="text" class="gf-form-input max-width-15" ng-model="ctrl.panel.limit" ng-change="ctrl.onRender()" />
1313
</div>
14+
<gf-form-switch class="gf-form" label="Alerts from this dashboard" label-class="width-18" checked="ctrl.panel.onlyAlertsOnDashboard" on-change="ctrl.updateStateFilter()"></gf-form-switch>
1415
</div>
1516
<div class="section gf-form-group">
1617
<h5 class="section-heading">State filter</h5>

public/app/plugins/panel/alertlist/module.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class AlertListPanel extends PanelCtrl {
2525
panelDefaults = {
2626
show: 'current',
2727
limit: 10,
28-
stateFilter: []
28+
stateFilter: [],
29+
onlyAlertsOnDashboard: false
2930
};
3031

3132

@@ -71,9 +72,13 @@ class AlertListPanel extends PanelCtrl {
7172
var params: any = {
7273
limit: this.panel.limit,
7374
type: 'alert',
74-
newState: this.panel.stateFilter
75+
newState: this.panel.stateFilter,
7576
};
7677

78+
if (this.panel.onlyAlertsOnDashboard) {
79+
params.dashboardId = this.dashboard.id;
80+
}
81+
7782
params.from = dateMath.parse(this.dashboard.time.from).unix() * 1000;
7883
params.to = dateMath.parse(this.dashboard.time.to).unix() * 1000;
7984

@@ -93,6 +98,10 @@ class AlertListPanel extends PanelCtrl {
9398
state: this.panel.stateFilter
9499
};
95100

101+
if (this.panel.onlyAlertsOnDashboard) {
102+
params.dashboardId = this.dashboard.id;
103+
}
104+
96105
this.backendSrv.get(`/api/alerts`, params)
97106
.then(res => {
98107
this.currentAlerts = _.map(res, al => {

0 commit comments

Comments
 (0)