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>
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>
* 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>
* 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>
* support loading webhook URL from a file
/cc #2498
Signed-off-by: Simon Rozet <me@simonrozet.com>
* notify/webhook: add test for reading url from file
Signed-off-by: Simon Rozet <me@simonrozet.com>
* notify/pushover: add tests for reading secrets from files
Signed-off-by: Simon Rozet <me@simonrozet.com>
---------
Signed-off-by: Simon Rozet <me@simonrozet.com>
* support loading pushover secrets from files
Add the user_key_file and token_file keys to the pushover config.
/cc https://github.com/prometheus/alertmanager/issues/2498
Signed-off-by: Simon Rozet <me@simonrozet.com>
* Update Go to 1.19
* Update Go.
* Update some Go modules.
* Update Swagger to the latest for Go 1.19 compatibility.
* api/v2: regenerate
* Accommodate to the changes in the client package
* asset/assets_vfsdata.go: regenerate
Signed-off-by: SuperQ <superq@gmail.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
- Move away from Webhook to APIRUL
- Make the Room ID a require field
- Set Authorization Credentails via Headers
Signed-off-by: gotjosh <josue.abreu@gmail.com>
Cisco's Webex has been one of the most requested notifiers on Grafana for a while now, please see: https://github.com/grafana/grafana/issues/11750#issue-318358659
Given it's straightforward implementation, low maintance overhead and request demand, I think it's worth including this directly in the Alertmanager.
Signed-off-by: gotjosh <josue.abreu@gmail.com>
While most integrations set a limit by UTF-8 compatible characters (some like Webex) use runes - as pointed out in https://github.com/prometheus/alertmanager/pull/3132. This PR makes it explicit wether the truncation is happening at a byte or rune level.
Signed-off-by: gotjosh <josue.abreu@gmail.com>
* Pass in response body to Retrier Check
* Custom error details for webhook notifier
Signed-off-by: Oktarian Tilney-Bassett <oktariantilneybassett@improbable.io>
It seems useless to keep the notifications in the nflog for longer than
twice the repeat interval. This should help reduce memory usage of
clustered alertmanagers.
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
We don't need to test `getPassword()` separately as it can be covered
with the tests already checking the various authentication methods.
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Add explicit UTC to time interval tests
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Add timezone support to time intervals
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Update time interval documentation with time zone info
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Refactor notification tests to test timezone support
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Make use of Local more clear
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Fix documentation about timezone support.
Makes it clear that the default is UTC, but others are supported.
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Remove commented/unused function
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Fix tests using incorrect timezones
Previously tests were using time zone names that were unsupported by the
RFC822 parser. This switches the tests to use RFC822Z and specifies the
zones by number.
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Add a few more timezone test cases
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Remove unnecessary if/else branch
Co-authored-by: Sylvain Rabot <sylvain@abstraction.fr>
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Rename timezone to location for consistency with Go stdlib
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Make Windows timezone error more specific
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Update docs to use 'location'
Signed-off-by: Ben Ridley <benridley29@gmail.com>
* Apply suggestions from code review
Co-authored-by: Sylvain Rabot <sylvain@abstraction.fr>
Signed-off-by: Ben Ridley <benridley29@gmail.com>
Signed-off-by: Ben Ridley <benridley29@gmail.com>
Co-authored-by: Sylvain Rabot <sylvain@abstraction.fr>
* SMTP config: add global and local password file fields
Add config fields (for both global email config and route-specific email
config) that specify path to file containing SMTP password. We don't
want the password in the config file itself, and reading the password
from a k8s-secret-backed file keeps the password itself "encrypted at
rest" in etcd, and cleanly separated from the rest of the AM config.
I used the same approach as pull request #2534 "Add support to set the
Slack URL in the file"
<https://github.com/prometheus/alertmanager/pull/2534/files> in the
upstream repo.
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* changed *AuthPasswordFile field types to string per review feedback
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* added error to getPassword() retval per review feedback
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* simplified conf.smtp-* files
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* update docs to reflect field type change
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* don't treat username-without-password as invalid
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* test cleanup
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* Apply suggestions from code review
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Eric R. Rath <4080262+ericrrath@users.noreply.github.com>
* Updated per review feedback
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* added sub-test per review feedback
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* added test on Email.getPassword() per feedback
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* only inherit global SMTP passwords if neither local password field is set
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
* removed blank line caught by gofumpt
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
Signed-off-by: Eric R. Rath <eric.rath@oracle.com>
Signed-off-by: Eric R. Rath <4080262+ericrrath@users.noreply.github.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>