Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move notifiers from Grafana (part 1) #24

Merged
merged 121 commits into from
Dec 16, 2022
Merged

Move notifiers from Grafana (part 1) #24

merged 121 commits into from
Dec 16, 2022

Conversation

yuri-tceretian
Copy link
Contributor

@yuri-tceretian yuri-tceretian commented Dec 16, 2022

This PR copies files

Moved files ``` base.go default_template.go default_template_test.go factory.go images.go log.go opsgenie.go opsgenie_test.go pagerduty.go pagerduty_test.go pushover.go pushover_test.go sender.go sensugo.go sensugo_test.go teams.go teams_test.go telegram.go telegram_test.go template_data.go threema.go threema_test.go util.go util_test.go webex.go webex_test.go webhook.go webhook_test.go wecom.go wecom_test.go ```

from Grafana repository keeping the history of modifications

Starting from 896c6b6 commits fix the code to be compliant with local linting rules and add some missing pieces from the Grafana repository that were scattered around Grafana repository.

codesome and others added 30 commits December 16, 2022 15:09
* AlertingNG: PagerDuty notification channel

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Add tests

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix lint

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix reviews

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* AlertingNG: Slack notification channel

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Add tests

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix review comments

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix review comments and small refactoring

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* NGAlert: Don't use pkg/errors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update pkg/services/ngalert/notifier/alertmanager.go

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>

* Fix logging

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
… (#33489)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* NGAlert: Add integration tests for notification channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix the failing tests

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix review comments

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Override creation of rule UID, remove only namespace UID

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* Alerting: Allow the notifier to log

The notifier upstream code uses go-kit as its logging library. The
grafana specific logger is not compatible with this API. In this PR, I
have created a wrapper that implements io.Writer to make them
compatible.
…036)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* [Alerting]: Add sensugo notification channel

* Apply suggestions from code review

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>

* Do not include labels with concatenated rule UID and names

* Modifications after syncing with main

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
* [Alerting]: Add Pushover integration with the alert manager

* lint

* Set boundary only for tests

* Remove title field

* fix imports
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* Alerting: Opsgenie notification channel

This translate the opsgenie notification channel from the old alerting
system to the new alerting system with a few changes:

- The tag system has been replaced in favour of annotation.
- TBD
- TBD

Signed-off-by: Josue Abreu <josue@grafana.com>

* Fix template URL

* Bugfig: dont send resolved when autoClose is false

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix integration tests

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix URLs in all other channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
…34662)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* NGAlert: Update the default template to include more URLs

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix tests

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* Alerting: Do not hard fail on templating errors in channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix review

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
…35749)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
…nd add `ValueString` variable in notifications (#36032)

* Alerting: Allow __value__ label in notifications
was being removed by removePrivateItems
discoverd in #36020, but issue is not about that specifically

* __value__ label to __value_string__ annotation
and .ValueString extended property for notifications
…sage where necessary (#36126)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
* Alerting: Improve receiver initialisation errors
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit adds contact point testing to ngalerts via a new API
endpoint. This endpoint accepts JSON containing a list of
receiver configurations which are validated and then tested
with a notification for a test alert. The endpoint returns JSON
for each receiver with a status and error message. It accepts
a configurable timeout via the Request-Timeout header (in seconds)
up to a maximum of 30 seconds.
Alex Moreno and others added 26 commits December 16, 2022 15:10
…524)

* Add custom title to pagerduty contact point

* Fix tests by saving decrypted key

* Use simplejson
* Add custom title to pushover contact point

* Update pkg/services/ngalert/notifier/channels/pushover.go

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

* Use simplejson

* Use more verbose variable names

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add title and description to Webhook contact point

* Remove deprecation message
* Alerting: Implement the Webex notifier

Closes grafana/grafana#11750

Signed-off-by: gotjosh <josue.abreu@gmail.com>
…coding/json to parse settings (#56834)

* update teams
* update sensugo
* update pushover
* update webhook to use json.Number
…ions (#59432)

* Break out image logic and add logging

* Attach alert log context to image attachment

* Fix capitalization
… (#58927)

* make severity a regular text field
* add logs + fallback to critical if empty
…son to parse settings (#58925)

* update pagerduty and opsgenie to deserialize settings using standard JSON library
* update pagerduty truncation to use a function from Alertamanger package
* update opsgenie to use payload model (same as in Alertmanager)
* replace yaml.v2 with yaml.v3

* fix a few tests due to the yaml.v3 api changes

* and another goconvey mistake in tests
…ent and Client URL (#59895)

* add support for source field
* add client_url
* use real host name for source placeholder
…manager (#59339)

* Move truncation code to util to mirror upstream

* Resolve merge conflicts

* Align logging of alert key

* Update tests and fix field passing bug

* Remove superfluous newline in test now that we trim whitespace

* Uptake minor log changes from upstream
…ing notifiers (#60271)

* create sender service interface and bridge to grafana notifier service
* update notifiers to use local sender interface
…ge (#60358)

* remove intermediate struct to create Base struct
* fix alertmanager
… (#60361)

* introduce Logger interface local to channles + implementaton that wraps the Grafana logger
* make NewFactoryConfig accept LoggerFactory
* add logger field to FactoryConfig
* update usages of log.Logger to internal interface
…ionChannelConfig (#60423)

* introduce alias for json.RawMessage with name RawMessage. This is needed to keep raw JSON and implement a marshaler for YAML, which does not seem to be used but there are tests that fail.
* replace usage of simplejson with RawMessage in NotificationChannelConfig
* remove usage of simplejson in tests
* change migration code to convert simplejson to raw message
will be removed after migration is done
Copy link
Collaborator

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet