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
04690ca9
Commit
04690ca9
authored
Sep 06, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(alerting): add support for retries
ref #5855
parent
0d7a8712
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
pkg/services/alerting/eval_context.go
+2
-0
pkg/services/alerting/eval_handler.go
+20
-0
No files found.
pkg/services/alerting/eval_context.go
View file @
04690ca9
...
...
@@ -26,6 +26,7 @@ type EvalContext struct {
dashboardSlug
string
ImagePublicUrl
string
ImageOnDiskPath
string
RetryCount
int
}
type
StateDescription
struct
{
...
...
@@ -111,5 +112,6 @@ func NewEvalContext(rule *Rule) *EvalContext {
DoneChan
:
make
(
chan
bool
,
1
),
CancelChan
:
make
(
chan
bool
,
1
),
log
:
log
.
New
(
"alerting.evalContext"
),
RetryCount
:
0
,
}
}
pkg/services/alerting/eval_handler.go
View file @
04690ca9
...
...
@@ -8,6 +8,10 @@ import (
"github.com/grafana/grafana/pkg/metrics"
)
var
(
MaxRetries
int
=
1
)
type
DefaultEvalHandler
struct
{
log
log
.
Logger
alertJobTimeout
time
.
Duration
...
...
@@ -28,8 +32,24 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) {
context
.
Error
=
fmt
.
Errorf
(
"Timeout"
)
context
.
EndTime
=
time
.
Now
()
e
.
log
.
Debug
(
"Job Execution timeout"
,
"alertId"
,
context
.
Rule
.
Id
)
e
.
retry
(
context
)
case
<-
context
.
DoneChan
:
e
.
log
.
Debug
(
"Job Execution done"
,
"timeMs"
,
context
.
GetDurationMs
(),
"alertId"
,
context
.
Rule
.
Id
,
"firing"
,
context
.
Firing
)
if
context
.
Error
!=
nil
{
e
.
retry
(
context
)
}
}
}
func
(
e
*
DefaultEvalHandler
)
retry
(
context
*
EvalContext
)
{
e
.
log
.
Debug
(
"Retrying eval exeuction"
,
"alertId"
,
context
.
Rule
.
Id
)
context
.
RetryCount
++
if
context
.
RetryCount
>
MaxRetries
{
context
.
DoneChan
=
make
(
chan
bool
,
1
)
context
.
CancelChan
=
make
(
chan
bool
,
1
)
e
.
Eval
(
context
)
}
}
...
...
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