Commit Graph

130 Commits

Author SHA1 Message Date
gotjosh f66bbab421
Fix tests after rebase
Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-06-17 13:20:21 +01:00
gotjosh cfb909f419
Marker: Rename `SetSilenced` to `SetActiveOrSilenced`
This accurately reflects what the function _actually_ does. If no active silences IDs are provided and the list of inhibitions we have is already empty the alert is actually set to Active. Took me a while to realise this as I was understanding how do we populate the alert list.

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-06-17 12:51:23 +01:00
gotjosh 805e505288
Alert metric reports different results to what the user sees via API (#2943)
* Alert metric reports different results to what the user sees via API

Fixes #1439 and #2619.

The previous metric is not _technically_ reporting incorrect results as the alerts _are_ still around and will be re-used if that same alert (equal fingerprint) is received before it is GCed. Therefore, I have kept the old metric under a new name `alertmanager_marked_alerts` and repurpose the current metric to match what the user sees in the UI.

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-06-16 12:16:06 +02: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
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
Björn Rabenstein fd0929ba9f
Merge pull request #2627 from prometheus/release-0.22
Merge release branch back into master
2021-06-23 13:41:56 +02:00
Peter Štibraný 15ea220f45 Don't return error from mem.Alerts.Put.
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
2021-05-31 10:05:04 +02:00
Peter Štibraný cc0b08fd7c Added possibility to pass callback to *mem.NewAlerts, useful for implementing limits on alerts.
Update provider/mem/mem.go

Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
2021-05-31 09:56:57 +02:00
beorn7 e84c265196 Include pending silences for future muting decisions
Previously, if a pending silence existed for an alert, and it later
became active without any silences getting added in the meantime, we
would miss the existence of that newly active silence.

Signed-off-by: beorn7 <beorn@grafana.com>
2021-05-27 22:15:57 +02:00
Simon Pasquier 25b32434a6
store: fix potential flaky test (#2077)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-10-22 09:25:31 +02:00
Simon Pasquier 4535311c34 dispatch: don't garbage-collect alerts from store
The aggregation group is already responsible for removing the resolved
alerts. Running the garbage collection in parallel introduces a race and
eventually resolved notifications may be dropped.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-09-18 11:42:14 +02:00
Simon Pasquier c78b449f4a provider/mem: fix dropped alerts
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-19 15:35:21 +02:00
Simon Pasquier 510cb2936f provider/mem: add test detecting dropped alerts
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-19 14:00:58 +02:00
Max Leonard Inden 09a7370572
main.go: Move marker metric registering into types/types.go
Instead of registering marker metrics inside of
cmd/alertmanager/main.go, register them in types/types.go, encapsulating
marker specific logic in its module, not in main.go. In addition it
paves the path for removing the usage of the global metric registry in
the future, by taking a local metric registerer.

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2019-02-05 14:59:22 +01:00
Steve Winslow 8ca1f66a2d Fixed typo in license statement URL
Signed-off-by: Steve Winslow <swinslow@gmail.com>
2018-12-02 08:12:09 -05:00
stuart nelson e883ccb9de
pull out shared code for storing alerts (#1507)
Move the code for storing and GC'ing alerts from being re-implemented in
several packages to existing in its own package

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2018-09-03 14:52:53 +02:00
Max Leonard Inden 1219541184
*.go: Introduce errcheck enforcing error handling
Errcheck [1] enforces error handling accross all go files. Functions can
be excluded via `scripts/errcheck_excludes.txt`.

This patch adds errcheck to the `test` Make target.

[1] https://github.com/kisielk/errcheck

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-08-30 15:47:13 +02:00
Sergiusz Urbaniak f9896e0162
provider/mem: cleanup closed listener in GC
... rather than in the Subscribe method. Currently the cleanup for a
given Alert subscription is done in a blocking goroutine, started in
the Subscribe method.

This simplifies it by moving the cleanup to the GC.

Additionally it simplifies the subscribe method by setting up the
buffered channel big enough to fill it up with all pending alerts
preventing the necessity to start a goroutine in Subscribe at all.

Signed-off-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>
2018-08-13 09:35:11 +02:00
Max Inden d4788ed195 provider/mem: Add `Put` `Subscribe` starvation test (#1503)
TestAlertsSubscribePutStarvation tests starvation of `iterator.Close` and
`alerts.Put`. Both `Subscribe` and `Put` use the Alerts.mtx lock. `Subscribe`
needs it to subscribe and more importantly unsubscribe `Alerts.listeners`.
`Put` uses the lock to add additional alerts and iterate the `Alerts.listeners`
map.  If the channel of a listener is at its limit, `alerts.Lock` is blocked,
whereby a listener can not unsubscribe as the lock is hold by `alerts.Lock`.

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-08-06 16:00:17 +02:00
wangYue 0fc0ff8e71 Avoid listener blocking (#1482)
Signed-off-by: wangyue <wangyue@actiontech.com>
2018-08-06 13:24:21 +02:00
pasquier-s 7b80919b36 Remove unused code (#1272) 2018-03-03 11:07:47 +01:00
pasquier-s e8a92f65ef Run staticcheck as part of the build process (#1264)
This change also fixes potential issues highlighted by running
staticcheck.
2018-02-28 17:42:32 +01:00
pasquier-s 29e441f88f Fix miscellaneous issues revealed by Go 1.10 (#1256)
* provider/mem: fix format verbs in tests

* api: fix format verb
2018-02-22 14:57:45 +00:00
Stuart Nelson b45c11b561 Fix tests 2018-01-21 15:38:19 +01:00
Jose Donizetti 2fe013bcaa Add tests to memory provider (#1104) 2018-01-21 15:27:21 +01:00
stuart nelson 69b97058f6 Fix tests 2017-12-19 15:43:23 +01:00
stuart nelson 481eab7b83 Make alertGC interval configurable 2017-12-19 15:36:38 +01:00
Fabian Reinartz 8170206070 Fix alert status handling in UI 2017-05-08 12:56:03 +02:00
stuart nelson 6a909abf17 Add processing status field to alert 2017-04-27 14:18:52 +02:00
Fabian Reinartz 3b5dfa8aba provider: delete old silence provider 2016-08-30 12:01:24 +02:00
Fabian Reinartz 1baf98fb1a provider: remove NotificationInfos provider 2016-08-23 13:57:19 +02:00
Fabian Reinartz 6a20296af4 *: fixup, remove bolt provider 2016-08-09 14:17:50 +02:00
Fabian Reinartz 96fa0bb468 provider/mesh: set expiration time on create 2016-08-09 12:01:31 +02:00
Fabian Reinartz bebda718c0 provider/mesh: use protobuf gossip format
stuff
2016-08-09 12:01:31 +02:00
Fabian Reinartz 91fd3f5b3a provider/mesh: use struct for string in state map 2016-08-09 12:01:31 +02:00
Fabian Reinartz 66c2171bd8 *: rename NotifyInfo to NotificationInfo 2016-08-09 12:01:31 +02:00
Fabian Reinartz 37eb2127b7 provider/mesh: add doc comments 2016-08-09 12:01:31 +02:00
Fabian Reinartz fdf09b6ae6 provider/mesh: implement snapshotting
This change adds snapshotting to the silences and notification infos
providers. Snapshots are created periodically and on shutdown. They are
loaded into memory on startup.
Periodic snapshotting is run right after garbage collection.
2016-08-09 12:01:31 +02:00
Fabian Reinartz c0103dd8c6 provider/mesh: filter deleted silences from results 2016-08-09 12:00:52 +02:00
Fabian Reinartz 022adbff36 provider/mesh: fix end timestamp for unstarted silences
This changes the end timestamp for unstarted silences to the
start timestamp so the silence remains valid by not having the end
time before the start time.
2016-08-09 12:00:52 +02:00
Fabian Reinartz a89ba5b5ca provider/mesh: allow timestamp equality tolerance 2016-08-09 12:00:28 +02:00
Fabian Reinartz ddd3189bfe provider/mesh: always store UTC 2016-08-09 12:00:28 +02:00
Fabian Reinartz 2a7047cdc1 *: fix golint warnings, add TODOs 2016-08-09 12:00:28 +02:00
Fabian Reinartz 00f1f1f8bf provider/mesh: fix silence end time modification 2016-08-09 12:00:28 +02:00
Fabian Reinartz 8a517b485d *: activate mesh garbage collection 2016-08-09 12:00:28 +02:00
Fabian Reinartz dfa79409ae provider/mesh: add silence garbage collection 2016-08-09 12:00:28 +02:00
Fabian Reinartz c1ee634c16 provider/mesh: add notification garbage collection 2016-08-09 12:00:28 +02:00
Fabian Reinartz 06a8700472 provider/mesh: fix and test modification validity
This change fixes, extends, and tests silenceModAllowed. It now can also
be applied to new silences.
2016-08-09 12:00:28 +02:00
Fabian Reinartz 57b60ba33e provider/mesh: add silence state del test 2016-08-09 12:00:28 +02:00
Fabian Reinartz 3d350a34b5 provider/mesh: extract silence deletion into state 2016-08-09 12:00:28 +02:00