71 Commits

Author SHA1 Message Date
a5d9196a53 Chore/fix lint issues (#27704)
* Chore: Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-09-22 16:22:19 +02:00
0c4b7d3f5d Alerting API: send 404 not found error and enrich delete with UID endpoint response with alert notification ID (#27550)
* Alerting API: Send back 404 not found error for update and delete endpoints

* Alerting API: send back alert notification id for delete with uid endpoint
2020-09-11 18:04:43 +02:00
292c985b76 Alerting: Support storing sensitive notifier settings securely/encrypted (#25114)
Support storing sensitive notification settings securely/encrypted.
Move slack notifier url and api token to secure settings.
Migrating slack notifier to store token and url encrypted is currently 
a manual process by saving an existing slack alert notification channel.
saving an existing slack alert notification channel will reset the stored 
non-secure url and token.

Closes #25113
Ref #25967

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2020-07-08 10:17:05 +02:00
44b7f3ea1c AlertNotifications: Translate notifications IDs to UIDs in Rule builder (#19882)
* AlertNotifications: Translate notifications IDs to UIDs in alert Rule builder

* Avoid shadowing errors, raise validation error on non-existing notification id

* create a cache for notification Uids to minimize db overhead

* add cache usage test

* avoid caching empty notification Uids

* isolate db in alert notificationUid caching tests
2020-03-18 15:00:56 +02:00
f9962eabff chore: avoid aliasing imports in services (#22499) 2020-02-29 13:35:15 +01:00
2a78d2a61c pkg/services: Check errors (#19712)
* pkg/services: Check errors
* pkg/services: Don't treat context.Canceled|context.DeadlineExceeded as error
2019-10-22 14:08:18 +02:00
54c1bf0cc9 Chore: a bit of spring cleaning (#16710)
* Chore: use early return technic everywhere

And enable "indent-error-flow" revive rule

* Chore: remove if-return rule from revive config

* Chore: improve error messages

And enable "error-strings" revive rule

* Chore: enable "error-naming" revive rule

* Chore: make linter happy

* Chore: do not duplicate gofmt execution

* Chore: make linter happy

* Chore: address the pull review comments
2019-04-23 11:24:47 +03:00
5da1faf454 Alerting: Notification channel http api fixes (#16379)
Fixes so it's possible to create new notification channel and providing uid.
Fixes better error/result handling when updating a notifcation channel.

Fixes #16372
Ref #16219 #16012
2019-04-04 17:52:40 +02:00
79b86466fd Fix: Alerting Notification channel http api fixes (#16288)
Fix so that uid can be changed when updating notification
channels through the http api.
Update documentation
2019-03-29 09:42:38 +01:00
2ae63e70c0 Alerting: Notification channel http api enhancements (#16219)
Now returns uid in response to get notification channel by id.
Adds GET/PUT/DELETE support for notification channel by uid, 
  /api/alert-notifications/uid/:uid.
Break apart alerting and alert notification http api docs in two 
  pages and update documentation to make it up to date
  with current implementation.

Fixes #16012
2019-03-26 18:37:02 +07:00
9a598be4f7 Fixed failing unit test 2019-01-29 21:17:56 +01:00
e218cc7637 docs: updates docs to refer to using uid 2019-01-28 22:03:16 +01:00
f461d52004 Converted notification id to uid via fmt for old alert notification settings 2019-01-16 16:52:00 +02:00
2de32756c2 Returned id for alert notifications which were created without uid 2019-01-16 16:52:00 +02:00
4bcace567b Formatted errors to err 2019-01-16 16:50:00 +02:00
f132e929ce Added uid for alert notifications 2019-01-16 16:50:00 +02:00
70385119bc removes d in disableResolvedMessage 2018-10-17 10:41:18 +02:00
c4dcf5a4ee fix gofmt, add test, correct noted concerns with default value 2018-10-16 17:33:38 -04:00
6376154b16 add channel option to disable the resolved alert (OK Message) that is sent when condition returns to normal. 2018-10-15 17:16:14 -04:00
418f77e70e get or create alert notification should use transaction 2018-10-02 15:07:44 +02:00
7b781e4c3c use notification state id instead of notifier id 2018-10-02 14:53:39 +02:00
67e5f62514 move version conflict logging for mark as complete to sqlstore package 2018-10-02 14:23:18 +02:00
9022e871e3 avoid sending full notification state to pending/complete 2018-10-02 13:57:41 +02:00
341d8af637 rename GetNotificationStateQuery to GetOrCreateNotificationStateQuery 2018-10-02 11:23:40 +02:00
7f1d7cefc0 reminder: uses UpdatedAt to track state changes. 2018-10-02 11:19:09 +02:00
75f832cda8 use alert state changes counter as secondary version 2018-10-01 15:58:30 +02:00
1be8fb76b8 cleanup alert_notification_state when deleting alert rules and channels 2018-09-30 21:57:15 +02:00
5ec086dc56 don't notify if notification state pending
If notification state is pending and last update of state was made
less than a minute ago. In the case of a grafana instance is shut down/crashes
between setting pending state and before sending the notification/marks as complete
this logic should allow the notification to be sent after some time instead of
being left in an inconsistent state where no notifications are being sent.
2018-09-30 21:52:50 +02:00
d412aafb7e remove unused code 2018-09-30 20:16:01 +02:00
67c58fa5e4 fix set sent_at on complete 2018-09-28 15:11:03 +02:00
c1763508e0 handle pending and completed state for alert notifications 2018-09-28 14:22:03 +02:00
69cc24ea3f wip: test get alert notification state 2018-09-28 11:17:03 +02:00
1a75aa54de wip: impl so that get alertstate also creates it if it does not exist 2018-09-28 10:48:08 +02:00
15ce474639 wip 2018-09-27 16:21:53 +02:00
d093244282 sqlstore: add support for checking if error is constraint validation error 2018-09-27 13:38:22 +02:00
c5278af6c4 add support for mysql and postgres unique index error codes 2018-09-27 11:33:13 +02:00
3fab616239 implement sql queries for transactional alert reminders 2018-09-27 11:14:44 +02:00
ff79f80685 initial rename refactoring 2018-09-27 09:43:00 +02:00
b04052f515 alerting: move all notification conditions to defaultShouldNotify 2018-09-26 14:34:10 +02:00
bb5aaa2dce pkg/services/sqlstore/alert_notification.go: Simplify err check
$ gometalinter --vendor --disable=all --enable=megacheck --deadline=10m ./...
pkg/services/sqlstore/alert_notification.go:242:3⚠️ 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (megacheck)
2018-09-18 23:42:20 +02:00
f73236f8f4 pkg/services/sqlstore: Fix x.Sql is deprecated: use SQL instead. (megacheck)
See,
$ gometalinter --vendor --disable-all --enable=megacheck --disable=gotype --deadline 6m ./... | grep SQL
alert.go:43:9⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
alert_notification.go:122:12⚠️ sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
annotation.go:226:12⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:228:9⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:302:10⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:416:9⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:635:12⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
migrations/user_mig.go:137:9⚠️ sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
plugin_setting.go:29:10⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:41:12⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:84:13⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:143:12⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:186:13⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:234:12⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
team.go:172:12⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
team.go:199:17⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
team.go:223:9⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
temp_user.go:99:10⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
temp_user.go:124:10⚠️ x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
user.go:375:3⚠️ sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
user.go:377:3⚠️ sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
user.go:379:3⚠️ sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
2018-09-16 12:26:05 +02:00
396f8e6464 notifications: read without tran, write with tran 2018-06-29 15:15:31 +02:00
83a12afc07 adds tests for journaling sql operations 2018-06-16 11:27:04 +02:00
12bf5c225a tests for defaultShouldNotify 2018-06-15 16:27:20 +02:00
f4b089d551 notifications: make journaling ctx aware 2018-06-15 15:30:17 +02:00
4a8e9cf93f removes more unused code 2018-06-07 07:15:50 +02:00
850aa21d45 removes unused code 2018-06-07 07:06:13 +02:00
171a38df99 alerting: fixes broken table rename 2018-06-05 14:29:48 +02:00
7333d7b8d4 alerting: invert sendOnce to sendReminder 2018-06-05 10:44:17 +02:00
93124f38fa alerting: only check frequency when not send once 2018-06-04 22:19:27 +02:00