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
caec36e7
Commit
caec36e7
authored
Nov 15, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alert rule have to be pending before alerting is for is specified
parent
7ba04466
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
pkg/services/alerting/eval_context.go
+1
-1
pkg/services/alerting/eval_context_test.go
+12
-2
No files found.
pkg/services/alerting/eval_context.go
View file @
caec36e7
...
...
@@ -126,7 +126,7 @@ func (c *EvalContext) GetNewState() m.AlertStateType {
}
since
:=
time
.
Now
()
.
Sub
(
c
.
Rule
.
LastStateChange
)
if
since
>
c
.
Rule
.
For
{
if
c
.
PrevAlertState
==
m
.
AlertStatePending
&&
since
>
c
.
Rule
.
For
{
return
m
.
AlertStateAlerting
}
...
...
pkg/services/alerting/eval_context_test.go
View file @
caec36e7
...
...
@@ -66,8 +66,8 @@ func TestGetStateFromEvalContext(t *testing.T) {
},
},
{
name
:
"ok ->
alerting. since its been firing for more than FOR
"
,
expected
:
models
.
AlertState
Alert
ing
,
name
:
"ok ->
pending. since it has to be pending longer than FOR and prev state is ok
"
,
expected
:
models
.
AlertState
Pend
ing
,
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStateOK
ec
.
Firing
=
true
...
...
@@ -76,6 +76,16 @@ func TestGetStateFromEvalContext(t *testing.T) {
},
},
{
name
:
"pending -> alerting. since its been firing for more than FOR and prev state is pending"
,
expected
:
models
.
AlertStateAlerting
,
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStatePending
ec
.
Firing
=
true
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
(
time
.
Hour
*
5
))
ec
.
Rule
.
For
=
time
.
Minute
*
2
},
},
{
name
:
"alerting -> alerting. should not update regardless of FOR"
,
expected
:
models
.
AlertStateAlerting
,
applyFn
:
func
(
ec
*
EvalContext
)
{
...
...
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