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
ea0cee4c
Unverified
Commit
ea0cee4c
authored
Jul 22, 2019
by
Kyle Brandt
Committed by
GitHub
Jul 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alerting: more specific error when missing threshold (#18221)
fixes #18184
parent
9cd069f2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
pkg/services/alerting/conditions/evaluator.go
+18
-2
pkg/services/alerting/conditions/query.go
+1
-1
No files found.
pkg/services/alerting/conditions/evaluator.go
View file @
ea0cee4c
...
@@ -34,8 +34,8 @@ type thresholdEvaluator struct {
...
@@ -34,8 +34,8 @@ type thresholdEvaluator struct {
func
newThresholdEvaluator
(
typ
string
,
model
*
simplejson
.
Json
)
(
*
thresholdEvaluator
,
error
)
{
func
newThresholdEvaluator
(
typ
string
,
model
*
simplejson
.
Json
)
(
*
thresholdEvaluator
,
error
)
{
params
:=
model
.
Get
(
"params"
)
.
MustArray
()
params
:=
model
.
Get
(
"params"
)
.
MustArray
()
if
len
(
params
)
==
0
{
if
len
(
params
)
==
0
||
params
[
0
]
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Evaluator
missing threshold parameter"
)
return
nil
,
fmt
.
Errorf
(
"Evaluator
'%v' is missing the threshold parameter"
,
HumanThresholdType
(
typ
)
)
}
}
firstParam
,
ok
:=
params
[
0
]
.
(
json
.
Number
)
firstParam
,
ok
:=
params
[
0
]
.
(
json
.
Number
)
...
@@ -139,3 +139,19 @@ func inSlice(a string, list []string) bool {
...
@@ -139,3 +139,19 @@ func inSlice(a string, list []string) bool {
}
}
return
false
return
false
}
}
// HumanThresholdType converts a treshold "type" string to a string that matches the UI
// so errors are less confusing.
func
HumanThresholdType
(
typ
string
)
string
{
switch
typ
{
case
"gt"
:
return
"IS ABOVE"
case
"lt"
:
return
"IS BELOW"
case
"within_range"
:
return
"IS WITHIN RANGE"
case
"outside_range"
:
return
"IS OUTSIDE RANGE"
}
return
""
}
pkg/services/alerting/conditions/query.go
View file @
ea0cee4c
...
@@ -234,7 +234,7 @@ func newQueryCondition(model *simplejson.Json, index int) (*QueryCondition, erro
...
@@ -234,7 +234,7 @@ func newQueryCondition(model *simplejson.Json, index int) (*QueryCondition, erro
evaluatorJSON
:=
model
.
Get
(
"evaluator"
)
evaluatorJSON
:=
model
.
Get
(
"evaluator"
)
evaluator
,
err
:=
NewAlertEvaluator
(
evaluatorJSON
)
evaluator
,
err
:=
NewAlertEvaluator
(
evaluatorJSON
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"error in condition %v: %v"
,
index
,
err
)
}
}
condition
.
Evaluator
=
evaluator
condition
.
Evaluator
=
evaluator
...
...
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