Commit Graph

437 Commits

Author SHA1 Message Date
TJ Hoplock f6b942cf9b
chore!: adopt log/slog, drop go-kit/log (#4089)
* chore!: adopt log/slog, drop go-kit/log

The bulk of this change set was automated by the following script which
is being used to aid in converting the various exporters/projects to use
slog:

https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434

This commit includes several changes:
- bump exporter-tookit to v0.13.1 for log/slog support
- updates golangci-lint deprecated configs
- enables sloglint linter
- removes old go-kit/log linter configs
- introduce some `if logger == nil { $newLogger }` additions to prevent
  nil references
- converts cluster membership config to use a stdlib compatible slog
  adapter, rather than creating a custom io.Writer for use as the
membership `logOutput` config

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* chore: address PR feedback

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

---------

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
2024-11-06 09:09:57 +00:00
Jeff Wong 95655dccb8
Discord notifier: Add username and avatar_url (#4081)
* Feat(discord):

Allow for custom username and avatar URLs to be set in discord notifications.

Add `username` and `avatar_url` to discord configuration, default empty string.

Re-implement #3821

Signed-off-by: Jeff Wong <awole20@gmail.com>

* Test the new fields

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* These are not templeatable strings

Signed-off-by: gotjosh <josue.abreu@gmail.com>

---------

Signed-off-by: Jeff Wong <awole20@gmail.com>
Signed-off-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
2024-10-24 21:12:05 +01:00
gotjosh 615d5ffa30
Add a test for `Notify` of the Discord integration (#4082)
Just to ensure this works correclty as expected, I originally thought there was a bug with the shadowing of the `content` varible but there isn't - to avoid further confusion I have followed up on this document left by George: https://github.com/prometheus/alertmanager/pull/3555#discussion_r1398448423

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2024-10-24 20:55:35 +01:00
Hottochelli 6b77acd166
Extend discord messages with content (#4007)
* Extend discord messages with content
Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>

Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>

* Updated configuration.md
Updated assets_vfsdata.go

Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>

* Fix grammar

Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>

* Updated vfsdata

Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>

---------

Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>
2024-10-23 19:27:01 +01:00
Kien Nguyen-Tuan a00a608355
fix(telegram): passing ParseMode when sending message (#4027)
Before commit [1], the message parse mode value is the same
as bot parse mode. Therefore, we don't need to pass ParseMode
whenever sending message. But after that commit, if we don't
pass SendOpts's ParseMode, the library will use the default
mode which is empty string "".

[1] 864bef4e4d

Signed-off-by: Kien Nguyen <kiennt2609@gmail.com>
2024-10-23 16:47:13 +01:00
Christoph Maser 8572fe849c
feat: add rocketchat notifier (#3600)
* feat: add rocketchat notifier

Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
Co-authored-by: George Robinson <george.robinson@grafana.com>

* Update notify/rocketchat/rocketchat.go

Co-authored-by: George Robinson <george.robinson@grafana.com>
Signed-off-by: gotjosh <josue.abreu@gmail.com>

---------

Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
Signed-off-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: George Robinson <george.robinson@grafana.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
2024-10-23 15:38:22 +01:00
Simon Schneider d4009f5e93
feat(3920): add msteamsv2 receiver (#4024)
* feat(3920): add msteamsv2 receiver

Signed-off-by: Simon Schneider <github@simon-schneider.eu>

* Don't use `fmt.Errorf` when there's no formatting required on `config/config.go`

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* Don't use `fmt.Errorf` when there's no formatting required on `config/notifiers.go`

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* Remove additional documentation steps

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* add more info to the documentation

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* Change documentation links to convey the message better

Signed-off-by: gotjosh <josue.abreu@gmail.com>

---------

Signed-off-by: Simon Schneider <github@simon-schneider.eu>
Signed-off-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
2024-10-23 11:31:27 +01:00
Danny Kopping 9c711fc6d1
fix: close SMTP submission correctly to handle errors (#4006)
* fix: close SMTP submission correctly to handle errors

Signed-off-by: Danny Kopping <dannykopping@gmail.com>

* lint

Signed-off-by: Danny Kopping <dannykopping@gmail.com>

* comments

Signed-off-by: Danny Kopping <dannykopping@gmail.com>

---------

Signed-off-by: Danny Kopping <dannykopping@gmail.com>
2024-08-30 15:17:15 +01:00
Simon Pasquier acebbedd10
chore: refactor the JIRA notifier
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2024-08-01 15:35:12 +02:00
Jan-Otto Kröpke a509c14b10
jira integration (#3590)
* Initial jira integration

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
2024-07-31 17:15:26 +02:00
Simon Pasquier 1e6ca4f66d
Merge pull request #3732 from sathieu/default_smtp_tls_config
Support default SMTP TLS config
2024-06-21 16:32:14 +02:00
George Robinson cc6de9c666 Remove Id return from silences.Set(*pb.Silence)
This commit removes the Id from the method silences.Set(*pb.Silence)
as it is redundant. The Id is still set even when creating a silence
fails. This will be fixed in a later change.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-06-20 15:47:49 +01:00
Emmanuel Lodovice 730bd752d1
Return error when TmplText errors in sns notifier (#3879)
* Return error when TmplText errors in sns notifier

Signed-off-by: Emmanuel Lodovice <lodovice@amazon.com>

* Use fmt.Errorf instead of errors.Wrap

Signed-off-by: Emmanuel Lodovice <lodovice@amazon.com>

---------

Signed-off-by: Emmanuel Lodovice <lodovice@amazon.com>
2024-06-17 09:44:11 +01:00
gotjosh 7e2cd80c2d
Revert "Return error when TmplText errors in sns notifier (#3531)" (#3876)
This reverts commit 603a72800e.
2024-06-14 10:27:32 +01:00
Emmanuel Lodovice 603a72800e
Return error when TmplText errors in sns notifier (#3531)
Signed-off-by: Emmanuel Lodovice <lodovice@amazon.com>
2024-06-13 08:21:49 +01:00
Marc Brugger 06b389bfec
allow webex roomID from template (#3801)
Signed-off-by: bakito <github@bakito.ch>
2024-05-30 14:20:38 +01:00
George Robinson c4a763c401
#3513: Mark muted alerts (#3793)
* Mark muted groups

This commit updates TimeMuteStage and TimeActiveStage to mark groups
as muted when its alerts are muted by an active or mute time interval,
and remove any existing markers when outside all active and mute
time intervals.

Signed-off-by: George Robinson <george.robinson@grafana.com>

* Remove unlock to defer

Signed-off-by: George Robinson <george.robinson@grafana.com>

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-05-13 11:16:26 +01:00
George Robinson dacbf0050b
#3513: TimeMuter returns the names of time intervals (#3791)
* TimeMuter returns the names of time intervals

This commit updates the TimeMuter interface to also return the names
of the time intervals that muted the alerts.

Signed-off-by: George Robinson <george.robinson@grafana.com>

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-04-30 12:47:00 +01:00
Gokhan a9b5cb4351
Enable setting ThreadId for Telegram notifications (#3638)
* Enable setting ThreadId for telegram notifications

Signed-off-by: Gokhan Sari <gokhan@sari.m

---------
Signed-off-by: gotjosh <josue.abreu@gmail.com>
2024-04-30 11:12:58 +01:00
Holger Freyther cb9724db47
notify/webhook: Fix crash on errors when url_file is used (#3798) (#3800) 2024-04-12 11:28:59 +02:00
George Robinson fc8c7d146f
#3513: Rewrite TestTimeMuteStage tests (#3794) 2024-04-11 13:53:50 +02:00
George Robinson 2dc23c90c9
Rewrite TestTimeActiveStage tests (#3795)
This commit rewrites the existing TestTimeActiveStage unit tests
to have complete isolation between test cases. Before this change,
each test case affected the state of its subsequent tests.

The motivation behind this change is to make it easier to assert
that alerts have been marked as muted.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-04-11 11:42:16 +02:00
George Robinson 342f6a599c
Add godot linter (#3613)
* Add godot linter

Signed-off-by: George Robinson <george.robinson@grafana.com>

* Remove extra line from LICENSE

Signed-off-by: George Robinson <george.robinson@grafana.com>

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-03-21 11:26:46 +00:00
George Krajcsovits d85bef20d9
feature: add native histogram support to latency metrics (#3737)
Note that this does not stop showing classic metrics, for now
it is up to the scrape config to decide whether to keep those instead or
both.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-02-29 14:53:47 +00:00
Mathieu Parent ef5e903418 Support default SMTP TLS config
Fixes: #3709

Signed-off-by: Mathieu Parent <math.parent@gmail.com>
2024-02-22 16:02:19 +01:00
gotjosh 80b3cb072f
Notify: Several improvements around the `suppressed_total` metric and logs for muting. (#3723) 2024-02-15 11:12:58 +00:00
TJ Hoplock f00025d037
feat: add counter to track alerts dropped outside of time_intervals (#3565)
* feat: add counter to track alerts dropped outside of time_intervals

Addresses: #3512

This adds a new counter metric `alertmanager_alerts_supressed_total`
that is incremented by `len(alerts)` when an alert is suppressed for
being outside of a time_interval, ie inside of a mute_time_intervals or
outside of an active_time_intervals.

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* test: add time interval suppression metric checks for notify

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* test: fix failure message log values in notifier

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* ref: address PR feedback for #3565

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* fix: track suppressed notifications metric for inhibit/silence

Based on PR feedback:

https://github.com/prometheus/alertmanager/pull/3565/files#r1393068026

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* fix: broken notifier tests

- fixed metric count check to properly check the diff between
  input/output notifications from the suppression to compare to suppression
metric, was previously inverted to compare to how many notifications it
suppressed.
- stopped using `Reset()` to compare collection counts between the
  multiple stages that are executed in `TestMuteStageWithSilences()`.
the intent was to compare a clean metric collection after each stage
execution, but the final stage where all silences are lifted results in
no metric being created in the test, causing `prom_testutil.ToFloat64()`
to panic. changed to separate vars to check counts between each stage,
with care to consider prior counts.

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>

* rename metric and add constants

Signed-off-by: gotjosh <josue.abreu@gmail.com>

---------

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
Signed-off-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
2024-02-13 11:17:24 +00:00
Philipp B 3d49ff83c7
feat: implement webhook_url_file for discord and msteams (#3555)
* feat: implement webhook_url_file for discord

implements #3482

Signed-off-by: Philipp Born <git@pborn.eu>

* feat: implement webhook_url_file for msteams

implements #3536

Signed-off-by: Philipp Born <git@pborn.eu>

---------

Signed-off-by: Philipp Born <git@pborn.eu>
2024-02-07 10:33:46 +00:00
Giorgio Gallo 4271a77bd0
Newlines in smtp password file are now ignored 2024-01-22 21:26:18 +01:00
Matthieu MOREL b9e347b9d1 golangci-lint: enable testifylint linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-12-10 08:50:03 +00:00
Matthieu MOREL b81bad8711 use Go standard errors
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-12-08 16:44:13 +01:00
Walther Lee 3416d5a4f5
Add context reasons to notifications failed counter (#3631)
---------

Signed-off-by: Walther Lee <walther.lee@reddit.com>
Co-authored-by: Walther Lee <walther.lee@reddit.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
2023-12-08 15:30:43 +01:00
romankubu 4f0bdf4940
Add summary to msteams notification (#3616)
* Add summary to msteams notification

Signed-off-by: Roman Kubu <Roman.Kubu@airbank.cz>
---------

Signed-off-by: Roman Kubu <Roman.Kubu@airbank.cz>
Signed-off-by: romankubu <112698283+romankubu@users.noreply.github.com>
Co-authored-by: Jack <jack4zhang@gmail.com>
2023-11-24 08:58:57 +00:00
Tomas Kozak d2b6692f2c
Reflect Discord's max length message limits (#3597)
* Reflect Discord's max length message limits

Signed-off-by: Tomas Kozak <kozak@talko.cz>

* Fix log key name

Signed-off-by: Tomas Kozak <kozak@talko.cz>

---------

Signed-off-by: Tomas Kozak <kozak@talko.cz>
2023-11-15 07:37:47 +00:00
George Robinson d2501323d2
Add debug logs for muted alerts (#3558)
This commit adds debug logs to MuteStage that logs when an alert
is muted. This can help operators root cause missing notifications
when alerts are silenced by mistake or purpose but then forgotten
about.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-24 18:00:38 +01:00
George Robinson 98290c3349
Add duration to the notify success message (#3559)
This commit updates Alertmanager to add a duration to the notify
success message. It complements the existing histogram to offer
fine-grained information about notification attempts. This can be
useful when debuggin duplicate notifications, for example, when
the duration exceeds peer_timeout.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-17 09:50:33 +01:00
gotjosh acb58400fd
Refactor: Move `inTimeIntervals` from `notify` to `timeinterval` (#3556)
* Refactor: Move `inTimeIntervals` from `notify` to `timeinterval`

There's absolutely no change of functionality here and I've expanded coverage for similar logic in both places.
---------

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2023-10-13 14:15:05 +01:00
gotjosh eef3708925
Remove duplicate integration from metrics
This is harmless as the vector won't be duplicated but let's remove it anyways.

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2023-09-08 15:26:36 +01:00
Colin Douch cfe4411deb
Add the receiver name to notification metrics (#3045)
* Add receiver name as a label to notify metrics

This commit adds in a second label to the notify family of metrics
(e.g. numTotalFailedNotifications) - the receiver name. This allows
disambiguating which receiver is failing when one has many receivers
with the same integration type

Signed-off-by: sinkingpoint <colin@quirl.co.nz>

* Gate receiver names behind a feature flag

Signed-off-by: sinkingpoint <colin@quirl.co.nz>

---------

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
Signed-off-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
2023-09-06 13:42:55 +01:00
Hélia Barroso ba303644e6
Add missing ttl in pushhover (#3474)
---------

Signed-off-by: Hélia Barroso <helia.barroso@farfetch.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2023-08-31 17:35:04 +02:00
Rita Canavarro 9063957924
[FEAT] Add missing integrations to notify metrics (#3480)
Signed-off-by: rita.canavarro <rita.canavarro@farfetch.com>
2023-08-24 21:20:42 +01:00
Anton Tolchanov 94625df2b2
Treat error response payloads from Slack as errors (#3121)
As described in the "More error types" section below, Slack API can return
errors with a 200 response code:
https://slack.dev/node-slack-sdk/web-api#handle-errors

This change adds parsing of API response to extract error messages.

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2023-08-10 10:59:13 +01:00
George Robinson 638f41c215
Log the GroupKey and alerts in retry (#3438)
This commit updates notify.go to log the GroupKey and fingerprints
of an alert at the debug level, and just the GroupKey at the
warning level should the notify attempt fail.

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-08-07 11:31:28 +01:00
Jack d10f21f38c
Add msteams (#3324)
* Add msteams

Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
---------
Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
Signed-off-by: Jack <jack4zhang@gmail.com>
2023-06-08 11:27:56 -04:00
Davide Bizzarri 140c3d683f notify/webhook: trim space from url_file content
Signed-off-by: Davide Bizzarri <davide.bizzarri@neoom.com>
2023-05-16 13:30:06 +02:00
Alec 3b9cd0408e
Add support for pushover devices (#3318)
* Add support for pushover devices

Signed-off-by: Alec Pinson <30310787+alec-pinson@users.noreply.github.com>

* update docs

Signed-off-by: Alec Pinson <30310787+alec-pinson@users.noreply.github.com>

---------

Signed-off-by: Alec Pinson <30310787+alec-pinson@users.noreply.github.com>
2023-05-05 13:04:47 +01:00
gotjosh 0f3ab929fa
Slack Notifier: Only return an error when it actually occurs (#3350) 2023-05-02 17:59:37 +01:00
gotjosh 4dc20154f6
add reason code to slack notifier (#3252)
* add reason code to slack notifier
this uses the new error with reason to determine based on status code what the reason is for the slack integration

partial #3231

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* Add some tests

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* Handle the error

Signed-off-by: gotjosh <josue.abreu@gmail.com>

---------

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2023-04-28 14:05:56 +01:00
r0nn f040f089aa
fix wechat notifier response field name (#3330)
Signed-off-by: gotjosh <josue.abreu@gmail.com>
2023-04-28 12:40:49 +01:00
Yijie Qin 9a8d1f976e
add reason code to notifiers (#3307)
* add reason code to notifiers

Signed-off-by: Yijie Qin <qinyijie@amazon.com>
2023-04-07 17:05:17 +02:00