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
70385119
Commit
70385119
authored
Oct 17, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removes d in disableResolvedMessage
parent
5566a61a
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
109 additions
and
109 deletions
+109
-109
pkg/api/dtos/alerting.go
+26
-26
pkg/models/alert_notifications.go
+26
-26
pkg/services/alerting/interfaces.go
+1
-1
pkg/services/alerting/notifiers/base.go
+21
-21
pkg/services/alerting/notifiers/base_test.go
+1
-1
pkg/services/sqlstore/alert_notification.go
+14
-14
pkg/services/sqlstore/alert_notification_test.go
+10
-10
pkg/services/sqlstore/migrations/alert_mig.go
+2
-2
public/app/features/alerting/NotificationsEditCtrl.ts
+1
-1
public/app/features/alerting/partials/notification_edit.html
+7
-7
No files found.
pkg/api/dtos/alerting.go
View file @
70385119
...
...
@@ -49,30 +49,30 @@ func formatShort(interval time.Duration) string {
func
NewAlertNotification
(
notification
*
models
.
AlertNotification
)
*
AlertNotification
{
return
&
AlertNotification
{
Id
:
notification
.
Id
,
Name
:
notification
.
Name
,
Type
:
notification
.
Type
,
IsDefault
:
notification
.
IsDefault
,
Created
:
notification
.
Created
,
Updated
:
notification
.
Updated
,
Frequency
:
formatShort
(
notification
.
Frequency
),
SendReminder
:
notification
.
SendReminder
,
DisableResolve
dMessage
:
notification
.
DisableResolved
Message
,
Settings
:
notification
.
Settings
,
Id
:
notification
.
Id
,
Name
:
notification
.
Name
,
Type
:
notification
.
Type
,
IsDefault
:
notification
.
IsDefault
,
Created
:
notification
.
Created
,
Updated
:
notification
.
Updated
,
Frequency
:
formatShort
(
notification
.
Frequency
),
SendReminder
:
notification
.
SendReminder
,
DisableResolve
Message
:
notification
.
DisableResolve
Message
,
Settings
:
notification
.
Settings
,
}
}
type
AlertNotification
struct
{
Id
int64
`json:"id"`
Name
string
`json:"name"`
Type
string
`json:"type"`
IsDefault
bool
`json:"isDefault"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
dMessage
bool
`json:"disableResolved
Message"`
Frequency
string
`json:"frequency"`
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
Settings
*
simplejson
.
Json
`json:"settings"`
Id
int64
`json:"id"`
Name
string
`json:"name"`
Type
string
`json:"type"`
IsDefault
bool
`json:"isDefault"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
Message
bool
`json:"disableResolve
Message"`
Frequency
string
`json:"frequency"`
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
Settings
*
simplejson
.
Json
`json:"settings"`
}
type
AlertTestCommand
struct
{
...
...
@@ -102,12 +102,12 @@ type EvalMatch struct {
}
type
NotificationTestCommand
struct
{
Name
string
`json:"name"`
Type
string
`json:"type"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
dMessage
bool
`json:"disableResolved
Message"`
Frequency
string
`json:"frequency"`
Settings
*
simplejson
.
Json
`json:"settings"`
Name
string
`json:"name"`
Type
string
`json:"type"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
Message
bool
`json:"disableResolve
Message"`
Frequency
string
`json:"frequency"`
Settings
*
simplejson
.
Json
`json:"settings"`
}
type
PauseAlertCommand
struct
{
...
...
pkg/models/alert_notifications.go
View file @
70385119
...
...
@@ -23,41 +23,41 @@ var (
)
type
AlertNotification
struct
{
Id
int64
`json:"id"`
OrgId
int64
`json:"-"`
Name
string
`json:"name"`
Type
string
`json:"type"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
dMessage
bool
`json:"disableResolved
Message"`
Frequency
time
.
Duration
`json:"frequency"`
IsDefault
bool
`json:"isDefault"`
Settings
*
simplejson
.
Json
`json:"settings"`
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
Id
int64
`json:"id"`
OrgId
int64
`json:"-"`
Name
string
`json:"name"`
Type
string
`json:"type"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
Message
bool
`json:"disableResolve
Message"`
Frequency
time
.
Duration
`json:"frequency"`
IsDefault
bool
`json:"isDefault"`
Settings
*
simplejson
.
Json
`json:"settings"`
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
}
type
CreateAlertNotificationCommand
struct
{
Name
string
`json:"name" binding:"Required"`
Type
string
`json:"type" binding:"Required"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
dMessage
bool
`json:"disableResolved
Message"`
Frequency
string
`json:"frequency"`
IsDefault
bool
`json:"isDefault"`
Settings
*
simplejson
.
Json
`json:"settings"`
Name
string
`json:"name" binding:"Required"`
Type
string
`json:"type" binding:"Required"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
Message
bool
`json:"disableResolve
Message"`
Frequency
string
`json:"frequency"`
IsDefault
bool
`json:"isDefault"`
Settings
*
simplejson
.
Json
`json:"settings"`
OrgId
int64
`json:"-"`
Result
*
AlertNotification
}
type
UpdateAlertNotificationCommand
struct
{
Id
int64
`json:"id" binding:"Required"`
Name
string
`json:"name" binding:"Required"`
Type
string
`json:"type" binding:"Required"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
dMessage
bool
`json:"disableResolved
Message"`
Frequency
string
`json:"frequency"`
IsDefault
bool
`json:"isDefault"`
Settings
*
simplejson
.
Json
`json:"settings" binding:"Required"`
Id
int64
`json:"id" binding:"Required"`
Name
string
`json:"name" binding:"Required"`
Type
string
`json:"type" binding:"Required"`
SendReminder
bool
`json:"sendReminder"`
DisableResolve
Message
bool
`json:"disableResolve
Message"`
Frequency
string
`json:"frequency"`
IsDefault
bool
`json:"isDefault"`
Settings
*
simplejson
.
Json
`json:"settings" binding:"Required"`
OrgId
int64
`json:"-"`
Result
*
AlertNotification
...
...
pkg/services/alerting/interfaces.go
View file @
70385119
...
...
@@ -27,7 +27,7 @@ type Notifier interface {
GetNotifierId
()
int64
GetIsDefault
()
bool
GetSendReminder
()
bool
GetDisableResolve
d
Message
()
bool
GetDisableResolveMessage
()
bool
GetFrequency
()
time
.
Duration
}
...
...
pkg/services/alerting/notifiers/base.go
View file @
70385119
...
...
@@ -14,14 +14,14 @@ const (
)
type
NotifierBase
struct
{
Name
string
Type
string
Id
int64
IsDeault
bool
UploadImage
bool
SendReminder
bool
DisableResolve
d
Message
bool
Frequency
time
.
Duration
Name
string
Type
string
Id
int64
IsDeault
bool
UploadImage
bool
SendReminder
bool
DisableResolveMessage
bool
Frequency
time
.
Duration
log
log
.
Logger
}
...
...
@@ -34,15 +34,15 @@ func NewNotifierBase(model *models.AlertNotification) NotifierBase {
}
return
NotifierBase
{
Id
:
model
.
Id
,
Name
:
model
.
Name
,
IsDeault
:
model
.
IsDefault
,
Type
:
model
.
Type
,
UploadImage
:
uploadImage
,
SendReminder
:
model
.
SendReminder
,
DisableResolve
dMessage
:
model
.
DisableResolved
Message
,
Frequency
:
model
.
Frequency
,
log
:
log
.
New
(
"alerting.notifier."
+
model
.
Name
),
Id
:
model
.
Id
,
Name
:
model
.
Name
,
IsDeault
:
model
.
IsDefault
,
Type
:
model
.
Type
,
UploadImage
:
uploadImage
,
SendReminder
:
model
.
SendReminder
,
DisableResolve
Message
:
model
.
DisableResolve
Message
,
Frequency
:
model
.
Frequency
,
log
:
log
.
New
(
"alerting.notifier."
+
model
.
Name
),
}
}
...
...
@@ -84,8 +84,8 @@ func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalC
}
}
// Do not notify when state is OK if DisableResolve
d
Message is set to true
if
context
.
Rule
.
State
==
models
.
AlertStateOK
&&
n
.
DisableResolve
d
Message
{
// Do not notify when state is OK if DisableResolveMessage is set to true
if
context
.
Rule
.
State
==
models
.
AlertStateOK
&&
n
.
DisableResolveMessage
{
return
false
}
...
...
@@ -112,8 +112,8 @@ func (n *NotifierBase) GetSendReminder() bool {
return
n
.
SendReminder
}
func
(
n
*
NotifierBase
)
GetDisableResolve
d
Message
()
bool
{
return
n
.
DisableResolve
d
Message
func
(
n
*
NotifierBase
)
GetDisableResolveMessage
()
bool
{
return
n
.
DisableResolveMessage
}
func
(
n
*
NotifierBase
)
GetFrequency
()
time
.
Duration
{
...
...
pkg/services/alerting/notifiers/base_test.go
View file @
70385119
...
...
@@ -182,7 +182,7 @@ func TestBaseNotifier(t *testing.T) {
Convey
(
"default value should be false for backwards compatibility"
,
func
()
{
base
:=
NewNotifierBase
(
model
)
So
(
base
.
DisableResolve
d
Message
,
ShouldBeFalse
)
So
(
base
.
DisableResolveMessage
,
ShouldBeFalse
)
})
})
}
pkg/services/sqlstore/alert_notification.go
View file @
70385119
...
...
@@ -66,7 +66,7 @@ func GetAlertNotificationsToSend(query *m.GetAlertNotificationsToSendQuery) erro
alert_notification.updated,
alert_notification.settings,
alert_notification.is_default,
alert_notification.disable_resolve
d
_message,
alert_notification.disable_resolve_message,
alert_notification.send_reminder,
alert_notification.frequency
FROM alert_notification
...
...
@@ -107,7 +107,7 @@ func getAlertNotificationInternal(query *m.GetAlertNotificationsQuery, sess *DBS
alert_notification.updated,
alert_notification.settings,
alert_notification.is_default,
alert_notification.disable_resolve
d
_message,
alert_notification.disable_resolve_message,
alert_notification.send_reminder,
alert_notification.frequency
FROM alert_notification
...
...
@@ -168,16 +168,16 @@ func CreateAlertNotificationCommand(cmd *m.CreateAlertNotificationCommand) error
}
alertNotification
:=
&
m
.
AlertNotification
{
OrgId
:
cmd
.
OrgId
,
Name
:
cmd
.
Name
,
Type
:
cmd
.
Type
,
Settings
:
cmd
.
Settings
,
SendReminder
:
cmd
.
SendReminder
,
DisableResolve
dMessage
:
cmd
.
DisableResolved
Message
,
Frequency
:
frequency
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
IsDefault
:
cmd
.
IsDefault
,
OrgId
:
cmd
.
OrgId
,
Name
:
cmd
.
Name
,
Type
:
cmd
.
Type
,
Settings
:
cmd
.
Settings
,
SendReminder
:
cmd
.
SendReminder
,
DisableResolve
Message
:
cmd
.
DisableResolve
Message
,
Frequency
:
frequency
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
IsDefault
:
cmd
.
IsDefault
,
}
if
_
,
err
=
sess
.
MustCols
(
"send_reminder"
)
.
Insert
(
alertNotification
);
err
!=
nil
{
...
...
@@ -213,7 +213,7 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error {
current
.
Type
=
cmd
.
Type
current
.
IsDefault
=
cmd
.
IsDefault
current
.
SendReminder
=
cmd
.
SendReminder
current
.
DisableResolve
dMessage
=
cmd
.
DisableResolved
Message
current
.
DisableResolve
Message
=
cmd
.
DisableResolve
Message
if
current
.
SendReminder
{
if
cmd
.
Frequency
==
""
{
...
...
@@ -228,7 +228,7 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error {
current
.
Frequency
=
frequency
}
sess
.
UseBool
(
"is_default"
,
"send_reminder"
)
sess
.
UseBool
(
"is_default"
,
"send_reminder"
,
"disable_resolve_message"
)
if
affected
,
err
:=
sess
.
ID
(
cmd
.
Id
)
.
Update
(
current
);
err
!=
nil
{
return
err
...
...
pkg/services/sqlstore/alert_notification_test.go
View file @
70385119
...
...
@@ -219,7 +219,7 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
So
(
cmd
.
Result
.
OrgId
,
ShouldNotEqual
,
0
)
So
(
cmd
.
Result
.
Type
,
ShouldEqual
,
"email"
)
So
(
cmd
.
Result
.
Frequency
,
ShouldEqual
,
10
*
time
.
Second
)
So
(
cmd
.
Result
.
DisableResolve
d
Message
,
ShouldBeFalse
)
So
(
cmd
.
Result
.
DisableResolveMessage
,
ShouldBeFalse
)
Convey
(
"Cannot save Alert Notification with the same name"
,
func
()
{
err
=
CreateAlertNotificationCommand
(
cmd
)
...
...
@@ -228,20 +228,20 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
Convey
(
"Can update alert notification"
,
func
()
{
newCmd
:=
&
models
.
UpdateAlertNotificationCommand
{
Name
:
"NewName"
,
Type
:
"webhook"
,
OrgId
:
cmd
.
Result
.
OrgId
,
SendReminder
:
true
,
DisableResolve
d
Message
:
true
,
Frequency
:
"60s"
,
Settings
:
simplejson
.
New
(),
Id
:
cmd
.
Result
.
Id
,
Name
:
"NewName"
,
Type
:
"webhook"
,
OrgId
:
cmd
.
Result
.
OrgId
,
SendReminder
:
true
,
DisableResolveMessage
:
true
,
Frequency
:
"60s"
,
Settings
:
simplejson
.
New
(),
Id
:
cmd
.
Result
.
Id
,
}
err
:=
UpdateAlertNotification
(
newCmd
)
So
(
err
,
ShouldBeNil
)
So
(
newCmd
.
Result
.
Name
,
ShouldEqual
,
"NewName"
)
So
(
newCmd
.
Result
.
Frequency
,
ShouldEqual
,
60
*
time
.
Second
)
So
(
newCmd
.
Result
.
DisableResolve
d
Message
,
ShouldBeTrue
)
So
(
newCmd
.
Result
.
DisableResolveMessage
,
ShouldBeTrue
)
})
Convey
(
"Can update alert notification to disable sending of reminders"
,
func
()
{
...
...
pkg/services/sqlstore/migrations/alert_mig.go
View file @
70385119
...
...
@@ -71,8 +71,8 @@ func addAlertMigrations(mg *Migrator) {
mg
.
AddMigration
(
"Add column send_reminder"
,
NewAddColumnMigration
(
alert_notification
,
&
Column
{
Name
:
"send_reminder"
,
Type
:
DB_Bool
,
Nullable
:
true
,
Default
:
"0"
,
}))
mg
.
AddMigration
(
"Add column disable_resolve
d
_message"
,
NewAddColumnMigration
(
alert_notification
,
&
Column
{
Name
:
"disable_resolve
d
_message"
,
Type
:
DB_Bool
,
Nullable
:
false
,
Default
:
"0"
,
mg
.
AddMigration
(
"Add column disable_resolve_message"
,
NewAddColumnMigration
(
alert_notification
,
&
Column
{
Name
:
"disable_resolve_message"
,
Type
:
DB_Bool
,
Nullable
:
false
,
Default
:
"0"
,
}))
mg
.
AddMigration
(
"add index alert_notification org_id & name"
,
NewAddIndexMigration
(
alert_notification
,
alert_notification
.
Indices
[
0
]))
...
...
public/app/features/alerting/NotificationsEditCtrl.ts
View file @
70385119
...
...
@@ -12,7 +12,7 @@ export class AlertNotificationEditCtrl {
defaults
:
any
=
{
type
:
'email'
,
sendReminder
:
false
,
disableResolve
d
Message
:
false
,
disableResolveMessage
:
false
,
frequency
:
'15m'
,
settings
:
{
httpMethod
:
'POST'
,
...
...
public/app/features/alerting/partials/notification_edit.html
View file @
70385119
...
...
@@ -21,28 +21,28 @@
<gf-form-switch
class=
"gf-form"
label=
"Send on all alerts"
label-class=
"width-1
2
"
label-class=
"width-1
4
"
checked=
"ctrl.model.isDefault"
tooltip=
"Use this notification for all alerts"
>
</gf-form-switch>
<gf-form-switch
class=
"gf-form"
label=
"Include image"
label-class=
"width-1
2
"
label-class=
"width-1
4
"
checked=
"ctrl.model.settings.uploadImage"
tooltip=
"Captures an image and include it in the notification"
>
</gf-form-switch>
<gf-form-switch
class=
"gf-form"
label=
"Disable Resolve
d
Message"
label-class=
"width-1
2
"
checked=
"ctrl.model.disableResolve
d
Message"
tooltip=
"Disable the resolve
d
message [OK] that is sent when alerting state returns to false"
>
label=
"Disable Resolve Message"
label-class=
"width-1
4
"
checked=
"ctrl.model.disableResolveMessage"
tooltip=
"Disable the resolve message [OK] that is sent when alerting state returns to false"
>
</gf-form-switch>
<gf-form-switch
class=
"gf-form"
label=
"Send reminders"
label-class=
"width-1
2
"
label-class=
"width-1
4
"
checked=
"ctrl.model.sendReminder"
tooltip=
"Send additional notifications for triggered alerts"
>
</gf-form-switch>
...
...
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