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
dfb1b191
Commit
dfb1b191
authored
Nov 15, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented operator based firiing in backend
parent
b2db2b26
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
pkg/services/alerting/conditions/query.go
+7
-1
pkg/services/alerting/eval_handler.go
+5
-4
pkg/services/alerting/interfaces.go
+1
-0
No files found.
pkg/services/alerting/conditions/query.go
View file @
dfb1b191
...
...
@@ -23,6 +23,7 @@ type QueryCondition struct {
Query
AlertQuery
Reducer
QueryReducer
Evaluator
AlertEvaluator
Operator
string
HandleRequest
tsdb
.
HandleRequestFunc
}
...
...
@@ -72,6 +73,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) (*alerting.Conditio
return
&
alerting
.
ConditionResult
{
Firing
:
evalMatchCount
>
0
,
NoDataFound
:
emptySerieCount
==
len
(
seriesList
),
Operator
:
c
.
Operator
,
EvalMatches
:
matches
,
},
nil
}
...
...
@@ -168,8 +170,12 @@ func NewQueryCondition(model *simplejson.Json, index int) (*QueryCondition, erro
if
err
!=
nil
{
return
nil
,
err
}
condition
.
Evaluator
=
evaluator
operatorJson
:=
model
.
Get
(
"operator"
)
operator
:=
operatorJson
.
Get
(
"type"
)
.
MustString
()
condition
.
Operator
=
operator
return
&
condition
,
nil
}
...
...
pkg/services/alerting/eval_handler.go
View file @
dfb1b191
...
...
@@ -32,10 +32,11 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) {
break
}
// break if result has not triggered yet
if
cr
.
Firing
==
false
{
firing
=
false
break
// calculating Firing based on operator
if
cr
.
Operator
==
"or"
{
firing
=
firing
||
cr
.
Firing
}
else
{
firing
=
firing
&&
cr
.
Firing
}
context
.
EvalMatches
=
append
(
context
.
EvalMatches
,
cr
.
EvalMatches
...
)
...
...
pkg/services/alerting/interfaces.go
View file @
dfb1b191
...
...
@@ -24,6 +24,7 @@ type Notifier interface {
type
ConditionResult
struct
{
Firing
bool
NoDataFound
bool
Operator
string
EvalMatches
[]
*
EvalMatch
}
...
...
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