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
51511dd6
Commit
51511dd6
authored
May 30, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): save alert state
parent
1686d86c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
6 deletions
+17
-6
pkg/services/alerting/alert_rule_reader.go
+6
-4
pkg/services/alerting/alerting.go
+9
-0
pkg/services/alerting/executor.go
+1
-1
pkg/services/alerting/graphite/graphite.go
+1
-1
No files found.
pkg/services/alerting/alert_rule_reader.go
View file @
51511dd6
...
@@ -18,14 +18,16 @@ func (this AlertRuleReader) Fetch() []m.AlertRule {
...
@@ -18,14 +18,16 @@ func (this AlertRuleReader) Fetch() []m.AlertRule {
//{Id: 4, Title: "alert rule 4", Interval: "10s", Frequency: 5},
//{Id: 4, Title: "alert rule 4", Interval: "10s", Frequency: 5},
//{Id: 5, Title: "alert rule 5", Interval: "10s", Frequency: 5},
//{Id: 5, Title: "alert rule 5", Interval: "10s", Frequency: 5},
{
{
Id
:
6
,
Id
:
1
,
OrgId
:
1
,
OrgId
:
1
,
Title
:
"alert rule
6
"
,
Title
:
"alert rule
1
"
,
Interval
:
"10s"
,
Interval
:
"10s"
,
Frequency
:
3
,
Frequency
:
3
,
DatasourceId
:
1
,
DatasourceId
:
1
,
WarnOperator
:
">"
,
WarnOperator
:
"<"
,
WarnLevel
:
100
,
WarnLevel
:
3
,
CritOperator
:
"<"
,
CritLevel
:
4
,
Aggregator
:
"avg"
,
Aggregator
:
"avg"
,
Query
:
`{"refId":"A","target":"statsd.fakesite.counters.session_start.*.count","textEditor":true}"`
,
Query
:
`{"refId":"A","target":"statsd.fakesite.counters.session_start.*.count","textEditor":true}"`
,
QueryRange
:
"1h"
,
QueryRange
:
"1h"
,
...
...
pkg/services/alerting/alerting.go
View file @
51511dd6
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"time"
"time"
//"github.com/grafana/grafana/pkg/bus"
//"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/log"
m
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/setting"
...
@@ -132,6 +133,14 @@ func (this *Scheduler) HandleResponses() {
...
@@ -132,6 +133,14 @@ func (this *Scheduler) HandleResponses() {
if
this
.
jobs
[
response
.
Id
]
!=
nil
{
if
this
.
jobs
[
response
.
Id
]
!=
nil
{
this
.
jobs
[
response
.
Id
]
.
running
=
false
this
.
jobs
[
response
.
Id
]
.
running
=
false
}
}
cmd
:=
m
.
UpdateAlertStateCommand
{
AlertId
:
response
.
Id
,
NewState
:
response
.
State
,
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
log
.
Error
(
1
,
"failed to save state"
,
err
)
}
}
}
}
}
...
...
pkg/services/alerting/executor.go
View file @
51511dd6
...
@@ -34,7 +34,7 @@ func (this *ExecutorImpl) Execute(rule m.AlertRule, responseQueue chan *AlertRes
...
@@ -34,7 +34,7 @@ func (this *ExecutorImpl) Execute(rule m.AlertRule, responseQueue chan *AlertRes
response
,
err
:=
graphite
.
GraphiteClient
{}
.
GetSeries
(
rule
)
response
,
err
:=
graphite
.
GraphiteClient
{}
.
GetSeries
(
rule
)
if
err
!=
nil
{
if
err
!=
nil
{
responseQueue
<-
&
AlertResult
{
State
:
"
CRITICAL
"
,
Id
:
rule
.
Id
}
responseQueue
<-
&
AlertResult
{
State
:
"
PENDING
"
,
Id
:
rule
.
Id
}
}
}
responseQueue
<-
this
.
ValidateRule
(
rule
,
response
)
responseQueue
<-
this
.
ValidateRule
(
rule
,
response
)
...
...
pkg/services/alerting/graphite/graphite.go
View file @
51511dd6
...
@@ -48,7 +48,7 @@ func (this GraphiteClient) GetSeries(rule m.AlertRule) (m.TimeSeriesSlice, error
...
@@ -48,7 +48,7 @@ func (this GraphiteClient) GetSeries(rule m.AlertRule) (m.TimeSeriesSlice, error
}
}
if
res
.
StatusCode
!=
http
.
StatusOK
{
if
res
.
StatusCode
!=
http
.
StatusOK
{
return
nil
,
fmt
.
Errorf
(
"e
rror!"
)
return
nil
,
fmt
.
Errorf
(
"e
xpected httpstatus 200, found %d"
,
res
.
StatusCode
)
}
}
timeSeries
:=
make
([]
*
m
.
TimeSeries
,
0
)
timeSeries
:=
make
([]
*
m
.
TimeSeries
,
0
)
...
...
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