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
ccd89eee
Commit
ccd89eee
authored
Nov 05, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renames `debouceduration` to `for`
parent
d25284a3
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
24 deletions
+24
-24
pkg/models/alert.go
+1
-1
pkg/services/alerting/eval_context.go
+2
-2
pkg/services/alerting/eval_context_test.go
+4
-4
pkg/services/alerting/extractor.go
+6
-6
pkg/services/alerting/rule.go
+2
-2
pkg/services/sqlstore/migrations/alert_mig.go
+2
-2
public/app/features/alerting/AlertTabCtrl.ts
+1
-1
public/app/features/alerting/partials/alert_tab.html
+6
-6
No files found.
pkg/models/alert.go
View file @
ccd89eee
...
...
@@ -78,7 +78,7 @@ type Alert struct {
Silenced
bool
ExecutionError
string
Frequency
int64
DebounceDuration
time
.
Duration
For
time
.
Duration
EvalData
*
simplejson
.
Json
NewStateDate
time
.
Time
...
...
pkg/services/alerting/eval_context.go
View file @
ccd89eee
...
...
@@ -132,9 +132,9 @@ func (c *EvalContext) GetNewState() m.AlertStateType {
return
c
.
Rule
.
ExecutionErrorState
.
ToAlertState
()
}
if
c
.
Firing
&&
c
.
Rule
.
DebounceDuration
!=
0
{
if
c
.
Firing
&&
c
.
Rule
.
For
!=
0
{
since
:=
time
.
Now
()
.
Sub
(
c
.
Rule
.
LastStateChange
)
if
since
>
c
.
Rule
.
DebounceDuration
{
if
since
>
c
.
Rule
.
For
{
return
m
.
AlertStateAlerting
}
...
...
pkg/services/alerting/eval_context_test.go
View file @
ccd89eee
...
...
@@ -62,7 +62,7 @@ func TestGetStateFromEvalContext(t *testing.T) {
ec
.
PrevAlertState
=
models
.
AlertStateOK
ec
.
Firing
=
true
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
2
)
ec
.
Rule
.
DebounceDuration
=
time
.
Minute
*
5
ec
.
Rule
.
For
=
time
.
Minute
*
5
},
},
{
...
...
@@ -72,7 +72,7 @@ func TestGetStateFromEvalContext(t *testing.T) {
ec
.
PrevAlertState
=
models
.
AlertStateOK
ec
.
Firing
=
true
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
(
time
.
Hour
*
5
))
ec
.
Rule
.
DebounceDuration
=
time
.
Minute
*
2
ec
.
Rule
.
For
=
time
.
Minute
*
2
},
},
{
...
...
@@ -82,7 +82,7 @@ func TestGetStateFromEvalContext(t *testing.T) {
ec
.
PrevAlertState
=
models
.
AlertStateAlerting
ec
.
Firing
=
true
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
5
)
ec
.
Rule
.
DebounceDuration
=
time
.
Minute
*
2
ec
.
Rule
.
For
=
time
.
Minute
*
2
},
},
{
...
...
@@ -91,7 +91,7 @@ func TestGetStateFromEvalContext(t *testing.T) {
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStateOK
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
5
)
ec
.
Rule
.
DebounceDuration
=
time
.
Minute
*
2
ec
.
Rule
.
For
=
time
.
Minute
*
2
},
},
{
...
...
pkg/services/alerting/extractor.go
View file @
ccd89eee
...
...
@@ -114,12 +114,12 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json,
return
nil
,
ValidationError
{
Reason
:
"Could not parse frequency"
}
}
raw
Debouce
:=
jsonAlert
.
Get
(
"debounceDuration
"
)
.
MustString
()
var
debounceDuration
time
.
Duration
if
raw
Debouce
!=
""
{
debounceDuration
,
err
=
time
.
ParseDuration
(
rawDebouce
)
raw
Fow
:=
jsonAlert
.
Get
(
"for
"
)
.
MustString
()
var
forValue
time
.
Duration
if
raw
Fow
!=
""
{
forValue
,
err
=
time
.
ParseDuration
(
rawFow
)
if
err
!=
nil
{
return
nil
,
ValidationError
{
Reason
:
"Could not parse
debounceDuration
"
}
return
nil
,
ValidationError
{
Reason
:
"Could not parse
for
"
}
}
}
...
...
@@ -132,7 +132,7 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json,
Handler
:
jsonAlert
.
Get
(
"handler"
)
.
MustInt64
(),
Message
:
jsonAlert
.
Get
(
"message"
)
.
MustString
(),
Frequency
:
frequency
,
DebounceDuration
:
debounceDuration
,
For
:
forValue
,
}
for
_
,
condition
:=
range
jsonAlert
.
Get
(
"conditions"
)
.
MustArray
()
{
...
...
pkg/services/alerting/rule.go
View file @
ccd89eee
...
...
@@ -20,7 +20,7 @@ type Rule struct {
Name
string
Message
string
LastStateChange
time
.
Time
DebounceDuration
time
.
Duration
For
time
.
Duration
NoDataState
m
.
NoDataOption
ExecutionErrorState
m
.
ExecutionErrorOption
State
m
.
AlertStateType
...
...
@@ -104,7 +104,7 @@ func NewRuleFromDBAlert(ruleDef *m.Alert) (*Rule, error) {
model
.
Frequency
=
ruleDef
.
Frequency
model
.
State
=
ruleDef
.
State
model
.
LastStateChange
=
ruleDef
.
NewStateDate
model
.
DebounceDuration
=
ruleDef
.
DebounceDuration
model
.
For
=
ruleDef
.
For
model
.
NoDataState
=
m
.
NoDataOption
(
ruleDef
.
Settings
.
Get
(
"noDataState"
)
.
MustString
(
"no_data"
))
model
.
ExecutionErrorState
=
m
.
ExecutionErrorOption
(
ruleDef
.
Settings
.
Get
(
"executionErrorState"
)
.
MustString
(
"alerting"
))
model
.
StateChanges
=
ruleDef
.
StateChanges
...
...
pkg/services/sqlstore/migrations/alert_mig.go
View file @
ccd89eee
...
...
@@ -134,7 +134,7 @@ func addAlertMigrations(mg *Migrator) {
mg
.
AddMigration
(
"add index alert_notification_state org_id & alert_id & notifier_id"
,
NewAddIndexMigration
(
alert_notification_state
,
alert_notification_state
.
Indices
[
0
]))
mg
.
AddMigration
(
"Add
decounce_duration
to alert table"
,
NewAddColumnMigration
(
alertV1
,
&
Column
{
Name
:
"
debounce_duration
"
,
Type
:
DB_BigInt
,
Nullable
:
true
,
mg
.
AddMigration
(
"Add
for
to alert table"
,
NewAddColumnMigration
(
alertV1
,
&
Column
{
Name
:
"
for
"
,
Type
:
DB_BigInt
,
Nullable
:
true
,
}))
}
public/app/features/alerting/AlertTabCtrl.ts
View file @
ccd89eee
...
...
@@ -169,7 +169,7 @@ export class AlertTabCtrl {
alert
.
frequency
=
alert
.
frequency
||
'1m'
;
alert
.
handler
=
alert
.
handler
||
1
;
alert
.
notifications
=
alert
.
notifications
||
[];
alert
.
debounceDuration
=
alert
.
debounceDuration
||
'5m'
;
alert
.
for
=
alert
.
for
||
'5m'
;
const
defaultName
=
this
.
panel
.
title
+
' alert'
;
alert
.
name
=
alert
.
name
||
defaultName
;
...
...
public/app/features/alerting/partials/alert_tab.html
View file @
ccd89eee
...
...
@@ -28,16 +28,16 @@
<h5
class=
"section-heading"
>
Alert Config
</h5>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-6"
>
Name
</span>
<input
type=
"text"
class=
"gf-form-input width-2
2
"
ng-model=
"ctrl.alert.name"
>
<input
type=
"text"
class=
"gf-form-input width-2
0
"
ng-model=
"ctrl.alert.name"
>
</div>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-
8
"
>
Evaluate every
</span>
<input
class=
"gf-form-input max-width-
5
"
type=
"text"
ng-model=
"ctrl.alert.frequency"
>
<span
class=
"gf-form-label width-
9
"
>
Evaluate every
</span>
<input
class=
"gf-form-input max-width-
6
"
type=
"text"
ng-model=
"ctrl.alert.frequency"
>
</div>
<div
class=
"gf-form max-width-1
5
"
>
<label
class=
"gf-form-label width-
10"
>
Debounce duration
</label>
<input
type=
"text"
class=
"gf-form-input max-width-
5"
ng-model=
"ctrl.alert.debounceDuration
"
spellcheck=
'false'
placeholder=
"5m"
>
<div
class=
"gf-form max-width-1
1
"
>
<label
class=
"gf-form-label width-
5"
>
For
</label>
<input
type=
"text"
class=
"gf-form-input max-width-
6"
ng-model=
"ctrl.alert.for
"
spellcheck=
'false'
placeholder=
"5m"
>
<info-popover
mode=
"right-absolute"
>
Configuring this value means that an alert rule have to be firing for atleast this duration before changing state.
This should reduce false positive alerts and avoid flapping alerts.
...
...
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