45 Commits

Author SHA1 Message Date
7f8daa0eae Refactor: Change sqlstore.inTransaction to .WithTransactionalDBSession (#43245)
* Refactor: Change sqlstore.inTransaction(...) to SQLStore.WithTransactionalDBSession(...) in alert_notification.go

* Chore: Fix BE lint err

* fix: fix failing sqlstore nil error

* chore: remove unecessary setup()

* fix: use appropriate ctx
2022-01-06 18:21:39 +01:00
7936c4c522 Rename AddHandlerCtx to AddHandler (#43557) 2021-12-28 16:08:07 +01:00
a404a311da add context in the alert_notification (#41307) 2021-11-05 16:41:24 +08:00
2f0fe16759 Chore: Remove GoConvey from sqlstore package (#40753)
* refactor login attempt test

* refactor tags saving test

* refactor transaction tests

* refactor temporary user tests

* refactor dashboard version tests

* refactor dashboard provisioning tests

* refactor alert notification test

* refactor alert tests

* refactor acl tests
2021-10-21 14:09:19 +02:00
722c414fef Encryption: Refactor securejsondata.SecureJsonData to stop relying on global functions (#38865)
* Encryption: Add support to encrypt/decrypt sjd

* Add datasources.Service as a proxy to datasources db operations

* Encrypt ds.SecureJsonData before calling SQLStore

* Move ds cache code into ds service

* Fix tlsmanager tests

* Fix pluginproxy tests

* Remove some securejsondata.GetEncryptedJsonData usages

* Add pluginsettings.Service as a proxy for plugin settings db operations

* Add AlertNotificationService as a proxy for alert notification db operations

* Remove some securejsondata.GetEncryptedJsonData usages

* Remove more securejsondata.GetEncryptedJsonData usages

* Fix lint errors

* Minor fixes

* Remove encryption global functions usages from ngalert

* Fix lint errors

* Minor fixes

* Minor fixes

* Remove securejsondata.DecryptedValue usage

* Refactor the refactor

* Remove securejsondata.DecryptedValue usage

* Move securejsondata to migrations package

* Move securejsondata to migrations package

* Minor fix

* Fix integration test

* Fix integration tests

* Undo undesired changes

* Fix tests

* Add context.Context into encryption methods

* Fix tests

* Fix tests

* Fix tests

* Trigger CI

* Fix test

* Add names to params of encryption service interface

* Remove bus from CacheServiceImpl

* Add logging

* Add keys to logger

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Add missing key to logger

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Undo changes in markdown files

* Fix formatting

* Add context to secrets service

* Rename decryptSecureJsonData to decryptSecureJsonDataFn

* Name args in GetDecryptedValueFn

* Add template back to NewAlertmanagerNotifier

* Copy GetDecryptedValueFn to ngalert

* Add logging to pluginsettings

* Fix pluginsettings test

Co-authored-by: Tania B <yalyna.ts@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-10-07 17:33:50 +03:00
643c7fa0cb Chore: update all +build statements (#38782) 2021-09-01 17:38:56 +03:00
28784935b8 Sort notification channels alphabetically (#37426)
Even without the ability to control the sort order or to filter, this notably improves usability for long lists of notification channels.

Partially fixes #20067.
2021-08-19 22:49:14 +02:00
48e753d888 Alerting: Log alert warnings for obsolete notifiers when extracting alerts and remove spammy error (#28162)
* Lower level of notification translation messages

* API: Log alert warnings when saving dashboard

* Remove spammy error

* Rename function parameter

* Apply suggestions from code review

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Apply suggestions from code review

* Fix test

* Change alertValidator return type

* Small fix

* Rename symbol

* Revert "Rename symbol"

This reverts commit 40b619b21a336a8f635daf7ef4241e44a03f0977.

* Revert "Small fix"

This reverts commit 2df8319d1d0e8b9e4a3d18b36711e3ff53e6fa81.

* Revert "Change alertValidator return type"

This reverts commit ad933863e32057cf02caabaa5799e3c14033770d.

* Revert "Fix test"

This reverts commit f728ece2db9d45e7a78d31992082700b3fb4931d.

* Revert "Apply suggestions from code review"

This reverts commit f35c5f52af06a60cc39c8adf1508dce5a9a67052.

* Revert "Apply suggestions from code review"

This reverts commit 7f95800c5f0f1a7b552b7124f5dbeba349cce1d8.

* Revert "Rename function parameter"

This reverts commit 95d3e75b00c110e3e355ba069dbcd89939c2bee2.

* Revert "API: Log alert warnings when saving dashboard"

This reverts commit 1ac5c3f281263a2cad5d4136589ce1ece706752b.

* Conditionally log translation failures

* Fix issue causing test to fail

* Fix test

* Log instead of propagating translations failures due to database errors

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-10-22 14:43:12 +03:00
4937f0daab SQLStore: Run tests as integration tests (#28265)
* sqlstore: Run tests as integration tests

* Truncate database instead of re-creating it on each test

* Fix test description

See https://github.com/grafana/grafana/pull/12129

* Fix lint issues

* Fix postgres dialect after review suggestion

* Rename and document functions after review suggestion

* Add periods

* Fix auto-increment value for mysql dialect

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2020-10-16 10:46:14 +03: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
1698c74ec1 Chore: Fix tests for Go 1.15 (#26957)
* Chore: Fix tests for Go 1.15
2020-08-12 17:45:03 +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
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
5566a61aef alerting: tests default value for disable resolve message 2018-10-17 09:53:03 +02:00
a3137e731d clean up tests 2018-10-16 20:39:07 -04:00
0eae7b077d fix gofmt, add test, correct noted concerns with default value 2018-10-16 17:38:59 -04:00
c4dcf5a4ee fix gofmt, add test, correct noted concerns with default value 2018-10-16 17:33:38 -04:00
18c73631ea rename UI Option, align with control, update tests 2018-10-16 07:12:32 -04: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
75f832cda8 use alert state changes counter as secondary version 2018-10-01 15:58:30 +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
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
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
eba147c1a3 change/add tests for alerting notification reminders 2018-08-24 19:09:19 +02:00
83a12afc07 adds tests for journaling sql operations 2018-06-16 11:27:04 +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
c0a9e5cf1d Fix tests 2018-06-04 13:19:14 +02:00
1dfff74da9 move database-specific code into dialects (#11884) 2018-05-10 16:54:21 +02:00
91fb2e07ce pkg: fix codespell issues 2018-04-13 20:31:29 +02:00
2ca7284a56 tech(notifications): splitt into 3 queries
closes #5883
2016-09-06 08:43:15 +02:00
c893e5d241 feat(notifications): add support for default notifications
ref #5883
2016-09-05 21:35:37 +02:00
1edd224168 feat(alerting): fixing failing unit tests 2016-08-01 14:34:58 +02:00
fa309ec925 feat(alerting): add default notification group 2016-06-20 15:24:48 +02:00
9a8416416d feat(alerting): converter for db model to notification 2016-06-16 08:16:16 +02:00
dbf3795aaf feat(alerting): add sql layer for alert notifications 2016-06-16 08:16:16 +02:00
8b91e57ef6 feat(alerting): notification query 2016-06-16 08:16:16 +02:00