Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
55af988e
Commit
55af988e
authored
Jun 09, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): mocking with new alert rule model
parent
c85bb476
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
23 deletions
+130
-23
alerting_model.json
+25
-3
public/app/plugins/panel/graph/alert_tab_ctrl.ts
+60
-9
public/app/plugins/panel/graph/partials/tab_alerting.html
+45
-11
No files found.
alerting_model.json
View file @
55af988e
...
...
@@ -136,10 +136,32 @@
"alert"
:
{
"name"
:
"CPU usage last 5min changed by more than 20% compared to last 24hours"
,
"frequency"
:
"1m"
,
"
valueExpr"
:
"query(#A, 5m, now, avg
)"
,
"evalType"
:
"percent change"
,
"
expr"
:
"query(#A, 5m, now, avg) percentGreaterThan(
)"
,
"evalType"
:
"percent
scre
change"
,
"evalExpr"
:
"query(#A, 1d, now, avg)"
,
"critLevel"
:
20
,
"warnLevel"
:
10
,
"warnLevel"
:
10
,
},
"alert"
:
{
"name"
:
"CPU usage last 5min changed by more than 20% compared to last 24hours"
,
"frequency"
:
"1m"
,
"valueQuery"
:
"query(#A, 5m, now, avg) "
,
"evalType"
:
"simple"
,
"// other options are: percent change, trend"
"evalQuery"
:
"query(#A, 1d, now, avg)"
,
"comparison"
:
"greater than"
,
"critLevel"
:
20
,
"warnLevel"
:
10
,
},
"alert"
:
{
"name"
:
"CPU usage last 5min changed by more than 20% compared to last 24hours"
,
"frequency"
:
"1m"
,
"valueQuery"
:
"query(#A, 5m, now, avg) | Evaluate Against: Static Threshold | >200 Warn | >300 Critical"
,
"valueQuery"
:
"query(#A, 5m, now, avg) | Evaluate Against: Percent Change Compared To | query(#B, 5m, now, avg) | >200 Warn | >300 Critical"
,
"valueQuery"
:
"query(#A, 5m, now, trend) | Evaluate Against: Forcast | 7days | >200 Warn | >300 Critical"
,
"evalType"
:
"simple"
,
"// other options are: percent change, trend"
"evalQuery"
:
"query(#A, 1d, now, avg)"
,
"comparison"
:
"greater than"
,
"critLevel"
:
20
,
"warnLevel"
:
10
,
},
}
public/app/plugins/panel/graph/alert_tab_ctrl.ts
View file @
55af988e
///<reference path="../../../headers/common.d.ts" />
///<reference path="../../../headers/common.d.ts" />
import
_
from
'lodash'
;
import
$
from
'jquery'
;
import
angular
from
'angular'
;
import
{
QueryPartDef
,
QueryPart
,
}
from
'app/core/components/query_part/query_part'
;
var
alertQueryDef
=
new
QueryPartDef
({
type
:
'query'
,
params
:
[
{
name
:
"queryRefId"
,
type
:
'string'
,
options
:
[
'#A'
,
'#B'
,
'#C'
,
'#D'
]},
{
name
:
"from"
,
type
:
"string"
,
options
:
[
'1s'
,
'10s'
,
'1m'
,
'5m'
,
'10m'
,
'15m'
,
'1h'
]},
{
name
:
"to"
,
type
:
"string"
,
options
:
[
'now'
]},
{
name
:
"aggregation"
,
type
:
"select"
,
options
:
[
'sum'
,
'avg'
,
'min'
,
'max'
,
'last'
]},
],
defaultParams
:
[
'#A'
,
'5m'
,
'now'
,
'avg'
]
});
export
class
AlertTabCtrl
{
panel
:
any
;
panelCtrl
:
any
;
alerting
:
any
;
metricTargets
=
[{
refId
:
'- select query -'
}
];
evalFuncs
=
[
'Greater Then'
,
'Percent Change'
];
evalFuncs
=
[
{
text
:
'Static Threshold'
,
value
:
'static'
,
},
{
text
:
'Percent Change Compared To'
,
value
:
'percent_change'
,
secondParam
:
"query"
,
},
{
text
:
'Forcast'
,
value
:
'forcast'
,
secondParam
:
"duration"
,
}
];
aggregators
=
[
'avg'
,
'sum'
,
'min'
,
'max'
,
'median'
];
rule
:
any
;
valueQuery
:
any
;
evalQuery
:
any
;
secondParam
:
any
;
defaultValues
=
{
aggregator
:
'avg'
,
frequency
:
10
,
queryRange
:
3600
,
warnOperator
:
'>'
,
critOperator
:
'>'
,
queryRef
:
'- select query -'
,
valueExpr
:
'query(#A, 5m, now, avg)'
,
evalFunc
:
'Greater Then'
,
evalExpr
:
''
,
evalFunc
:
'static'
,
critLevel
:
20
,
warnLevel
:
10
,
valueQuery
:
{
queryRefId
:
'A'
,
from
:
'5m'
,
to
:
'now'
,
agg
:
'avg'
,
},
evalQuery
:
{
queryRefId
:
'A'
,
from
:
'5m'
,
to
:
'now'
,
agg
:
'avg'
,
},
evalStringParam1
:
''
,
};
/** @ngInject */
...
...
@@ -36,15 +78,24 @@ export class AlertTabCtrl {
_
.
defaults
(
this
.
panel
.
alerting
,
this
.
defaultValues
);
this
.
rule
=
this
.
panel
.
alerting
;
this
.
valueQuery
=
new
QueryPart
(
this
.
rule
.
valueQuery
,
alertQueryDef
);
this
.
evalQuery
=
new
QueryPart
(
this
.
rule
.
evalQuery
,
alertQueryDef
);
var
defaultName
=
(
this
.
panelCtrl
.
dashboard
.
title
+
' '
+
this
.
panel
.
title
+
' alert'
);
this
.
panel
.
alerting
.
name
=
this
.
panel
.
alerting
.
name
||
defaultName
;
this
.
panel
.
targets
.
map
(
target
=>
{
this
.
metricTargets
.
push
(
target
);
});
this
.
panel
.
alerting
.
queryRef
=
this
.
panel
.
alerting
.
queryRef
||
this
.
metricTargets
[
0
].
refId
;
this
.
panel
.
alerting
.
queryRef
=
this
.
panel
.
alerting
.
queryRef
||
this
.
metricTargets
[
0
].
refId
;
this
.
convertThresholdsToAlertThresholds
();
this
.
evalFuncChanged
();
}
evalFuncChanged
()
{
var
evalFuncDef
=
_
.
findWhere
(
this
.
evalFuncs
,
{
value
:
this
.
rule
.
evalFunc
});
this
.
secondParam
=
evalFuncDef
.
secondParam
;
}
convertThresholdsToAlertThresholds
()
{
...
...
public/app/plugins/panel/graph/partials/tab_alerting.html
View file @
55af988e
<div
class=
"editor-row"
>
<div
class=
"gf-form-group
section
"
>
<div
class=
"gf-form-group"
>
<h5
class=
"section-heading"
>
Alert Rule
</h5>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label"
>
Value
</span>
<input
class=
"gf-form-input width-15"
type=
"text"
ng-model=
"ctrl.rule.valueExpr"
ng-change=
"ctrl.thresholdsUpdated()"
></input>
<query-part-editor
class=
"gf-form-label query-part"
part=
"ctrl.valueQuery"
part-updated=
"ctrl.valueQueryUpdated()"
>
</query-part-editor>
</div>
<div
class=
"gf-form"
>
<div
class=
"gf-form-select-wrapper max-width-10"
>
<select
class=
"gf-form-input"
ng-model=
"ctrl.rule.evalFunc"
ng-options=
"oper as oper for oper in ctrl.evalFuncs"
></select>
<span
class=
"gf-form-label"
>
Evaluate Against
</span>
<div
class=
"gf-form-select-wrapper"
>
<select
class=
"gf-form-input"
ng-model=
"ctrl.rule.evalFunc"
ng-options=
"f.value as f.text for f in ctrl.evalFuncs"
ng-change=
"ctrl.evalFuncChanged()"
>
</select>
</div>
</div>
<div
class=
"gf-form"
ng-if=
"ctrl.secondParam === 'query'"
>
<query-part-editor
class=
"gf-form-label query-part"
part=
"ctrl.evalQuery"
part-updated=
"ctrl.evalQueryUpdated()"
>
</query-part-editor>
</div>
<div
class=
"gf-form"
ng-if=
"ctrl.secondParam === 'duration'"
>
<span
class=
"gf-form-label"
>
Duration
</span>
<input
class=
"gf-form-input max-width-7"
type=
"text"
ng-model=
"ctrl.rule.evalStringParam1"
ng-change=
"ctrl.ruleUpdated()"
></input>
</div>
</div>
</div>
<div
class=
"gf-form-group"
>
<h5
class=
"section-heading"
>
Levels
</h5>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label"
>
<i
class=
"icon-gf icon-gf-warn alert-icon-warn"
></i>
Warn
Warn
if value
</span>
<input
class=
"gf-form-input max-width-7"
type=
"number"
ng-model=
"ctrl.panel.alerting.warnLevel"
ng-change=
"alertTab.thresholdsUpdated()"
></input>
<span
class=
"gf-form-label"
>
>
</span>
<input
class=
"gf-form-input max-width-7"
type=
"number"
ng-model=
"ctrl.rule.warnLevel"
ng-change=
"alertTab.thresholdsUpdated()"
></input>
</div>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label"
>
<i
class=
"icon-gf icon-gf-warn alert-icon-critical"
></i>
Critcal
Critcal
if value
</span>
<input
class=
"gf-form-input max-width-7"
type=
"number"
ng-model=
"ctrl.panel.alerting.warnLevel"
ng-change=
"alertTab.thresholdsUpdated()"
></input>
<span
class=
"gf-form-label"
>
>
</span>
<input
class=
"gf-form-input max-width-7"
type=
"number"
ng-model=
"ctrl.rule.critLevel"
ng-change=
"alertTab.thresholdsUpdated()"
></input>
</div>
</div>
</div>
</div>
<!-- <div class="gf-form"> -->
<!-- <span class="gf-form-label width-12">Aggregation method</span> -->
<!-- <div class="gf-form-select-wrapper max-width-10"> -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment