Commit Graph

31 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
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
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
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
gotjosh 217524d823
Merge pull request #3145 from alexweav/log-warn
Emit warning-level logs when truncating messages in notifications
2022-12-13 19:33:30 -04:00
Alex Weaver 0eee3ca9cb Rename key to max_runes
Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com>
2022-12-13 17:28:11 -06:00
Alex Weaver 42dcba213f Also log the length that values were truncated to
Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com>
2022-12-13 17:28:11 -06:00
Alex Weaver ed3cfbb124 Avoid logging the entire message after truncation
Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com>
2022-12-13 17:28:11 -06:00
Alex Weaver bb5804eca9 Change truncation log level to warn
Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com>
2022-12-13 17:28:11 -06:00
Ben Kochie 432ee01c8c
Update Go to 1.19 (#3150)
* 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>
2022-11-30 17:06:57 +01:00
gotjosh 4ecf5044dd
fix typo
Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-11-09 17:31:17 +00:00
gotjosh b3f50f0c84
Truncate: Be explicit on truncation of runes or bytes.
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>
2022-11-09 17:17:42 +00:00
Sarah Brofeldt 565d73da5e
Trim contents of slack api urls from files (#2929)
* Trim contents of slack api urls from files

Signed-off-by: Sarah Brofeldt <sarah@qtr.dk>

* notify/slack: fix test imports

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

Signed-off-by: Sarah Brofeldt <sarah@qtr.dk>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
2022-09-09 16:37:31 +02:00
inosato 791e542100 Remove ioutil
Signed-off-by: inosato <si17_21@yahoo.co.jp>
2022-07-18 22:01:02 +09:00
Matthias Loibl a6d10bd5bc
Update golangci-lint and fix complaints (#2853)
* Copy latest golangci-lint files from Prometheus

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Use grafana/regexp over stdlib regexp

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Fix typos in comments

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Fix goimports complains in import sorting

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* gofumpt all Go files

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Update naming to comply with revive linter

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* config: Fix error messages to be lower case

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* test/cli: Fix error messages to be lower case

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* .golangci.yaml: Remove obsolete space

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* config: Fix expected victorOps error

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Use stdlib regexp

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Clean up Go modules

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>
2022-03-25 17:59:51 +01:00
Prashant Balachandran a79a4baa1c adding max_alerts parameter to slack webhook config
correcting the logic to trucate fields instead of dropping alerts in the slack integration

Signed-off-by: Prashant Balachandran <pnair@redhat.com>
2021-12-21 16:32:49 +05:30
Julien Pivotto d59548fbab
Enable HTTP 2 again (#2720)
We are re-enabling HTTP 2 again. There has been a few bugfixes upstream
in go, and we have also enabled ReadIdleTimeout.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-11-10 17:28:47 +01:00
Julien Pivotto b2a4cacb95 Update go dependencies & switch to go-kit/log
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-08-02 12:43:23 +02:00
Marco Pracucci 04d683e880
Upgrade prometheus/common
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-04-21 12:01:34 +02:00
Marco Pracucci 37f4742922
Add HTTP client options to receiver integrations
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-04-21 11:56:20 +02:00
Julien Duchesne 59c7fd5053 Add support to set the Slack URL in a file
- Added support for the file in both the global and the lower level
- Tried to follow configuration patterns I saw in prometheus
- The slack file is read on every request as mentioned in the prometheus issue to enable seamless switches

https://github.com/prometheus/alertmanager/issues/2498
Signed-off-by: Julien Duchesne <julien.duchesne@grafana.com>
2021-04-01 21:59:49 -04:00
Julien Pivotto 470634d49f
Update common (#2353)
- Disable HTTP2: https://github.com/prometheus/common/pull/249
- Composite duration: https://github.com/prometheus/common/pull/246

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-08-25 15:48:59 +02:00
melchiormoulin e37f769035
Add slack channel when logging error. (#2177)
Signed-off-by: Melchior MOULIN <m.moulin@criteo.com>
2020-02-05 09:17:15 +01:00
Simon Pasquier b49ebfc683
Merge release 0.20 (#2140)
* Revert "slack: retry 429 errors (#2112)" (#2128)

This reverts commit 26cc96a787.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Revert "config: remove support for JSON marshaling (#2086)" (#2133)

This reverts commit 918f08b66a.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* config: fix JSON unmarshaling for HostPort (#2134)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Cut 0.20.0 (#2137)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-12-12 16:35:19 +01:00
Julien Pivotto 26cc96a787 slack: retry 429 errors (#2112)
Fix #2111

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2019-11-21 14:14:10 +01:00
Simon Pasquier 94d875f122
Bump prometheus/client_golang to v1.1.0 (#1989)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-08-08 14:36:10 +02:00
Simon Pasquier 655947d7e0
notify: refactor code to retry requests (#1974)
* notify: refactor code to retry requests

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* s/Process/Check/

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-08-02 16:17:40 +02:00
Asher Foa f45f870d2c Add the ability to configure slack markdown field (#1967)
* slack markdown field config

Signed-off-by: Asher Foa <asher@asherfoa.com>

* Add Test

Signed-off-by: Asher Foa <asher@asherfoa.com>

* remove empty lines

Signed-off-by: Asher Foa <asher@asherfoa.com>

* add empty line

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-07-31 12:04:59 +02:00
Simon Pasquier 0c3120efac *: split notify package
Instead of keeping all notifiers in the notify package, it splits them
into individual sub-packages. This improves readability and
maintainability of the code.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-06-18 15:36:19 +02:00