mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): more work on alert conditions
This commit is contained in:
@@ -32,7 +32,9 @@ export class AlertTabCtrl {
|
||||
handlers = [{text: 'Grafana', value: 1}, {text: 'External', value: 0}];
|
||||
conditionTypes = [
|
||||
{text: 'Query', value: 'query'},
|
||||
{text: 'Alert state', value: 'alert_state'},
|
||||
{text: 'Other alert', value: 'other_alert'},
|
||||
{text: 'Time of day', value: 'time_of_day'},
|
||||
{text: 'Day of week', value: 'day_of_week'},
|
||||
];
|
||||
alert: any;
|
||||
conditionModels: any;
|
||||
@@ -68,10 +70,6 @@ export class AlertTabCtrl {
|
||||
initModel() {
|
||||
var alert = this.alert = this.panel.alert = this.panel.alert || {};
|
||||
|
||||
// set threshold defaults
|
||||
alert.warn = this.getThresholdWithDefaults(alert.warn);
|
||||
alert.crit = this.getThresholdWithDefaults(alert.crit);
|
||||
|
||||
alert.conditions = alert.conditions || [];
|
||||
if (alert.conditions.length === 0) {
|
||||
alert.conditions.push(this.buildDefaultCondition());
|
||||
@@ -102,6 +100,8 @@ export class AlertTabCtrl {
|
||||
to: 'now',
|
||||
reducer: 'avg',
|
||||
reducerParams: [],
|
||||
warn: this.getThresholdWithDefaults({}),
|
||||
crit: this.getThresholdWithDefaults({}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
|
||||
<div ng-if="!ctrl.alert.enabled">
|
||||
<div class="gf-form-group">
|
||||
<h5 class="section-heading">Visual Thresholds</h5>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label">
|
||||
<i class="icon-gf icon-gf-warn alert-icon-critical"></i>
|
||||
Critcal if
|
||||
</span>
|
||||
<metric-segment-model property="ctrl.alert.crit.op" options="ctrl.operatorList" custom="false" css-class="query-segment-operator" on-change="ctrl.thresholdsUpdated()"></metric-segment-model>
|
||||
<input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.crit.value" ng-change="ctrl.thresholdsUpdated()"></input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label">
|
||||
<i class="icon-gf icon-gf-warn alert-icon-warn"></i>
|
||||
Warn if
|
||||
</span>
|
||||
<metric-segment-model property="ctrl.alert.warn.op" options="ctrl.operatorList" custom="false" css-class="query-segment-operator" on-change="ctrl.thresholdsUpdated()"></metric-segment-model>
|
||||
<input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.warn.value" ng-change="ctrl.thresholdsUpdated()"></input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div ng-if="!ctrl.alert.enabled"> -->
|
||||
<!-- <div class="gf-form-group"> -->
|
||||
<!-- <h5 class="section-heading">Visual Thresholds</h5> -->
|
||||
<!-- <div class="gf-form-inline"> -->
|
||||
<!-- <div class="gf-form"> -->
|
||||
<!-- <span class="gf-form-label"> -->
|
||||
<!-- <i class="icon-gf icon-gf-warn alert-icon-critical"></i> -->
|
||||
<!-- Critcal if -->
|
||||
<!-- </span> -->
|
||||
<!-- <metric-segment-model property="ctrl.alert.crit.op" options="ctrl.operatorList" custom="false" css-class="query-segment-operator" on-change="ctrl.thresholdsUpdated()"></metric-segment-model> -->
|
||||
<!-- <input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.crit.value" ng-change="ctrl.thresholdsUpdated()"></input> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="gf-form"> -->
|
||||
<!-- <span class="gf-form-label"> -->
|
||||
<!-- <i class="icon-gf icon-gf-warn alert-icon-warn"></i> -->
|
||||
<!-- Warn if -->
|
||||
<!-- </span> -->
|
||||
<!-- <metric-segment-model property="ctrl.alert.warn.op" options="ctrl.operatorList" custom="false" css-class="query-segment-operator" on-change="ctrl.thresholdsUpdated()"></metric-segment-model> -->
|
||||
<!-- <input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.warn.value" ng-change="ctrl.thresholdsUpdated()"></input> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<div ng-if="ctrl.alert.enabled">
|
||||
<div class="gf-form-group">
|
||||
@@ -69,7 +69,7 @@
|
||||
</query-part-editor>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label">Reduce</span>
|
||||
<span class="gf-form-label">Reducer</span>
|
||||
<query-part-editor
|
||||
class="gf-form-label query-part"
|
||||
part="conditionModel.reducerPart"
|
||||
@@ -102,24 +102,29 @@
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-inverse dropdown-toggle gf-form-btn" data-toggle="dropdown">
|
||||
<i class="fa fa-plus"></i> Add Condition
|
||||
</button>
|
||||
<div class="gf-form-button-row">
|
||||
<div class="dropdown pull-left" ng-if="ctrl.alert.enabled" >
|
||||
<button class="btn btn-inverse dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-plus"></i> Add Condition
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li ng-repeat="ct in ctrl.conditionTypes" role="menuitem">
|
||||
<a ng-click="ctrl.addCondition(ct.value);">{{ct.text}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li ng-repeat="ct in ctrl.conditionTypes" role="menuitem">
|
||||
<a ng-click="ctrl.addCondition(ct.value);">{{ct.text}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-inverse" ng-click="ctrl.delete()">
|
||||
Delete Alert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="editor-row">
|
||||
<div class="gf-form-group" ng-if="!ctrl.alert.enabled">
|
||||
<div class="gf-form-button-row">
|
||||
<button class="btn btn-danger" ng-click="ctrl.delete()" ng-show="ctrl.alert.enabled">Delete</button>
|
||||
<button class="btn btn-inverse" ng-click="ctrl.enable()" ng-hide="ctrl.alert.enabled">
|
||||
<button class="btn btn-inverse" ng-click="ctrl.enable()">
|
||||
<i class="icon-gf icon-gf-alert"></i>
|
||||
Create Alert
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user