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
28029ce4
Commit
28029ce4
authored
Nov 15, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alerting: support `for` on execution errors and notdata
parent
84eb3bd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
pkg/services/alerting/eval_context.go
+19
-13
No files found.
pkg/services/alerting/eval_context.go
View file @
28029ce4
...
...
@@ -118,7 +118,26 @@ func (c *EvalContext) GetRuleUrl() (string, error) {
return
fmt
.
Sprintf
(
urlFormat
,
m
.
GetFullDashboardUrl
(
ref
.
Uid
,
ref
.
Slug
),
c
.
Rule
.
PanelId
,
c
.
Rule
.
OrgId
),
nil
}
// GetNewState returns the new state from the alert rule evaluation
func
(
c
*
EvalContext
)
GetNewState
()
m
.
AlertStateType
{
ns
:=
getNewStateInternal
(
c
)
if
ns
!=
m
.
AlertStateAlerting
||
c
.
Rule
.
For
==
0
{
return
ns
}
since
:=
time
.
Now
()
.
Sub
(
c
.
Rule
.
LastStateChange
)
if
since
>
c
.
Rule
.
For
{
return
m
.
AlertStateAlerting
}
if
c
.
PrevAlertState
==
m
.
AlertStateAlerting
{
return
m
.
AlertStateAlerting
}
return
m
.
AlertStatePending
}
func
getNewStateInternal
(
c
*
EvalContext
)
m
.
AlertStateType
{
if
c
.
Error
!=
nil
{
c
.
log
.
Error
(
"Alert Rule Result Error"
,
"ruleId"
,
c
.
Rule
.
Id
,
...
...
@@ -132,19 +151,6 @@ func (c *EvalContext) GetNewState() m.AlertStateType {
return
c
.
Rule
.
ExecutionErrorState
.
ToAlertState
()
}
if
c
.
Firing
&&
c
.
Rule
.
For
!=
0
{
since
:=
time
.
Now
()
.
Sub
(
c
.
Rule
.
LastStateChange
)
if
since
>
c
.
Rule
.
For
{
return
m
.
AlertStateAlerting
}
if
c
.
PrevAlertState
==
m
.
AlertStateAlerting
{
return
m
.
AlertStateAlerting
}
return
m
.
AlertStatePending
}
if
c
.
Firing
{
return
m
.
AlertStateAlerting
}
...
...
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