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
c084145c
Commit
c084145c
authored
Sep 21, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(prometheus): add timerange to alert context
parent
af551b88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
pkg/services/alerting/conditions/query.go
+4
-4
pkg/services/alerting/eval_context.go
+2
-0
No files found.
pkg/services/alerting/conditions/query.go
View file @
c084145c
...
...
@@ -34,8 +34,8 @@ type AlertQuery struct {
}
func
(
c
*
QueryCondition
)
Eval
(
context
*
alerting
.
EvalContext
)
{
timerange
:
=
tsdb
.
NewTimerange
(
c
.
Query
.
From
,
c
.
Query
.
To
)
seriesList
,
err
:=
c
.
executeQuery
(
context
,
timerange
)
context
.
TimeRange
=
tsdb
.
NewTimerange
(
c
.
Query
.
From
,
c
.
Query
.
To
)
seriesList
,
err
:=
c
.
executeQuery
(
context
)
if
err
!=
nil
{
context
.
Error
=
err
return
...
...
@@ -69,7 +69,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
context
.
Firing
=
len
(
context
.
EvalMatches
)
>
0
}
func
(
c
*
QueryCondition
)
executeQuery
(
context
*
alerting
.
EvalContext
,
timerange
tsdb
.
TimeRange
)
(
tsdb
.
TimeSeriesSlice
,
error
)
{
func
(
c
*
QueryCondition
)
executeQuery
(
context
*
alerting
.
EvalContext
)
(
tsdb
.
TimeSeriesSlice
,
error
)
{
getDsInfo
:=
&
m
.
GetDataSourceByIdQuery
{
Id
:
c
.
Query
.
DatasourceId
,
OrgId
:
context
.
Rule
.
OrgId
,
...
...
@@ -79,7 +79,7 @@ func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timerange t
return
nil
,
fmt
.
Errorf
(
"Could not find datasource"
)
}
req
:=
c
.
getRequestForAlertRule
(
getDsInfo
.
Result
,
timer
ange
)
req
:=
c
.
getRequestForAlertRule
(
getDsInfo
.
Result
,
context
.
TimeR
ange
)
result
:=
make
(
tsdb
.
TimeSeriesSlice
,
0
)
resp
,
err
:=
c
.
HandleRequest
(
req
)
...
...
pkg/services/alerting/eval_context.go
View file @
c084145c
...
...
@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana/pkg/log"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb"
)
type
EvalContext
struct
{
...
...
@@ -28,6 +29,7 @@ type EvalContext struct {
ImageOnDiskPath
string
NoDataFound
bool
RetryCount
int
TimeRange
tsdb
.
TimeRange
}
type
StateDescription
struct
{
...
...
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