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
ea4b14ac
Commit
ea4b14ac
authored
Jun 17, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): rename critical -> crit
parent
212fd272
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
6 deletions
+9
-6
pkg/services/alerting/alert_rule.go
+1
-1
pkg/services/alerting/alert_rule_test.go
+4
-3
pkg/services/alerting/handler.go
+4
-2
No files found.
pkg/services/alerting/alert_rule.go
View file @
ea4b14ac
...
@@ -63,7 +63,7 @@ func NewAlertRuleFromDBModel(ruleDef *m.Alert) (*AlertRule, error) {
...
@@ -63,7 +63,7 @@ func NewAlertRuleFromDBModel(ruleDef *m.Alert) (*AlertRule, error) {
model
.
State
=
ruleDef
.
State
model
.
State
=
ruleDef
.
State
model
.
Frequency
=
ruleDef
.
Frequency
model
.
Frequency
=
ruleDef
.
Frequency
critical
:=
ruleDef
.
Settings
.
Get
(
"crit
ical
"
)
critical
:=
ruleDef
.
Settings
.
Get
(
"crit"
)
model
.
Critical
=
Level
{
model
.
Critical
=
Level
{
Operator
:
critical
.
Get
(
"op"
)
.
MustString
(),
Operator
:
critical
.
Get
(
"op"
)
.
MustString
(),
Value
:
critical
.
Get
(
"value"
)
.
MustFloat64
(),
Value
:
critical
.
Get
(
"value"
)
.
MustFloat64
(),
...
...
pkg/services/alerting/alert_rule_test.go
View file @
ea4b14ac
...
@@ -38,7 +38,7 @@ func TestAlertRuleModel(t *testing.T) {
...
@@ -38,7 +38,7 @@ func TestAlertRuleModel(t *testing.T) {
"description": "desc2",
"description": "desc2",
"handler": 0,
"handler": 0,
"enabled": true,
"enabled": true,
"crit
ical
": {
"crit": {
"value": 20,
"value": 20,
"op": ">"
"op": ">"
},
},
...
@@ -75,11 +75,12 @@ func TestAlertRuleModel(t *testing.T) {
...
@@ -75,11 +75,12 @@ func TestAlertRuleModel(t *testing.T) {
alertRule
,
err
:=
NewAlertRuleFromDBModel
(
alert
)
alertRule
,
err
:=
NewAlertRuleFromDBModel
(
alert
)
So
(
err
,
ShouldBeNil
)
So
(
err
,
ShouldBeNil
)
So
(
alertRule
.
Critical
.
Operator
,
ShouldEqual
,
">"
)
So
(
alertRule
.
Critical
.
Value
,
ShouldEqual
,
20
)
So
(
alertRule
.
Warning
.
Operator
,
ShouldEqual
,
">"
)
So
(
alertRule
.
Warning
.
Operator
,
ShouldEqual
,
">"
)
So
(
alertRule
.
Warning
.
Value
,
ShouldEqual
,
10
)
So
(
alertRule
.
Warning
.
Value
,
ShouldEqual
,
10
)
So
(
alertRule
.
Critical
.
Operator
,
ShouldEqual
,
">"
)
So
(
alertRule
.
Critical
.
Value
,
ShouldEqual
,
20
)
})
})
})
})
}
}
pkg/services/alerting/handler.go
View file @
ea4b14ac
...
@@ -102,7 +102,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice)
...
@@ -102,7 +102,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice)
transformedValue
,
_
:=
rule
.
Transformer
.
Transform
(
serie
)
transformedValue
,
_
:=
rule
.
Transformer
.
Transform
(
serie
)
critResult
:=
evalCondition
(
rule
.
Critical
,
transformedValue
)
critResult
:=
evalCondition
(
rule
.
Critical
,
transformedValue
)
e
.
log
.
Debug
(
"Alert execution Crit"
,
"name"
,
serie
.
Name
,
"transformedValue"
,
transformedValue
,
"operator"
,
rule
.
Critical
.
Operator
,
"level"
,
rule
.
Critical
.
Value
,
"result"
,
critResult
)
condition2
:=
fmt
.
Sprintf
(
"%v %s %v "
,
transformedValue
,
rule
.
Critical
.
Operator
,
rule
.
Critical
.
Value
)
e
.
log
.
Debug
(
"Alert execution Crit"
,
"name"
,
serie
.
Name
,
"condition"
,
condition2
,
"result"
,
critResult
)
if
critResult
{
if
critResult
{
triggeredAlert
=
append
(
triggeredAlert
,
&
TriggeredAlert
{
triggeredAlert
=
append
(
triggeredAlert
,
&
TriggeredAlert
{
State
:
alertstates
.
Critical
,
State
:
alertstates
.
Critical
,
...
@@ -113,7 +114,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice)
...
@@ -113,7 +114,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice)
}
}
warnResult
:=
evalCondition
(
rule
.
Warning
,
transformedValue
)
warnResult
:=
evalCondition
(
rule
.
Warning
,
transformedValue
)
e
.
log
.
Debug
(
"Alert execution Warn"
,
"name"
,
serie
.
Name
,
"transformedValue"
,
transformedValue
,
"operator"
,
rule
.
Warning
.
Operator
,
"level"
,
rule
.
Warning
.
Value
,
"result"
,
warnResult
)
condition
:=
fmt
.
Sprintf
(
"%v %s %v "
,
transformedValue
,
rule
.
Warning
.
Operator
,
rule
.
Warning
.
Value
)
e
.
log
.
Debug
(
"Alert execution Warn"
,
"name"
,
serie
.
Name
,
"condition"
,
condition
,
"result"
,
warnResult
)
if
warnResult
{
if
warnResult
{
triggeredAlert
=
append
(
triggeredAlert
,
&
TriggeredAlert
{
triggeredAlert
=
append
(
triggeredAlert
,
&
TriggeredAlert
{
State
:
alertstates
.
Warn
,
State
:
alertstates
.
Warn
,
...
...
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