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
77783c02
Commit
77783c02
authored
Sep 16, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(alerting): dont log null series
closes #6025
parent
852fd66c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
pkg/services/alerting/conditions/query.go
+5
-5
pkg/services/alerting/conditions/query_test.go
+12
-0
pkg/services/alerting/scheduler.go
+3
-2
No files found.
pkg/services/alerting/conditions/query.go
View file @
77783c02
...
...
@@ -43,6 +43,11 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
reducedValue
:=
c
.
Reducer
.
Reduce
(
series
)
evalMatch
:=
c
.
Evaluator
.
Eval
(
reducedValue
)
if
reducedValue
==
nil
{
emptySerieCount
++
continue
}
if
context
.
IsTestRun
{
context
.
Logs
=
append
(
context
.
Logs
,
&
alerting
.
ResultLogEntry
{
Message
:
fmt
.
Sprintf
(
"Condition[%d]: Eval: %v, Metric: %s, Value: %1.3f"
,
c
.
Index
,
evalMatch
,
series
.
Name
,
*
reducedValue
),
...
...
@@ -55,11 +60,6 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
Value
:
*
reducedValue
,
})
}
// handle no data scenario
if
reducedValue
==
nil
{
emptySerieCount
++
}
}
context
.
NoDataFound
=
emptySerieCount
==
len
(
seriesList
)
...
...
pkg/services/alerting/conditions/query_test.go
View file @
77783c02
...
...
@@ -85,6 +85,18 @@ func TestQueryCondition(t *testing.T) {
So
(
ctx
.
result
.
NoDataFound
,
ShouldBeTrue
)
})
Convey
(
"Should set NoDataFound both series contains null"
,
func
()
{
one
:=
float64
(
120
)
ctx
.
series
=
tsdb
.
TimeSeriesSlice
{
tsdb
.
NewTimeSeries
(
"test1"
,
[][
2
]
*
float64
{{
nil
,
&
one
}}),
tsdb
.
NewTimeSeries
(
"test2"
,
[][
2
]
*
float64
{{
nil
,
&
one
}}),
}
ctx
.
exec
()
So
(
ctx
.
result
.
Error
,
ShouldBeNil
)
So
(
ctx
.
result
.
NoDataFound
,
ShouldBeTrue
)
})
Convey
(
"Should not set NoDataFound if one serie is empty"
,
func
()
{
one
:=
float64
(
120
)
two
:=
float64
(
0
)
...
...
pkg/services/alerting/scheduler.go
View file @
77783c02
...
...
@@ -35,8 +35,9 @@ func (s *SchedulerImpl) Update(rules []*Rule) {
}
job
.
Rule
=
rule
job
.
Offset
=
((
rule
.
Frequency
*
1000
)
/
int64
(
len
(
rules
)))
*
int64
(
i
)
job
.
Offset
=
int64
(
math
.
Floor
(
float64
(
job
.
Offset
)
/
1000
))
offset
:=
((
rule
.
Frequency
*
1000
)
/
int64
(
len
(
rules
)))
*
int64
(
i
)
job
.
Offset
=
int64
(
math
.
Floor
(
float64
(
offset
)
/
1000
))
jobs
[
rule
.
Id
]
=
job
}
...
...
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