Commit Graph

144 Commits

Author SHA1 Message Date
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 Robinson 4d6ddd25c9
Fix panic in acceptance tests (#3592)
* Fix panic in acceptance tests

This commit attempts to address a panic that occurs in acceptance
tests if a server in the cluster fails to start.

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

* Remove started and check am.cmd.Process != nil

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

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-02-13 15:38:44 +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
George Robinson 4494abfce4
Fix UTF-8 not supported in group_by (#3619)
* Fix UTF-8 not supported in group_by

This commit fixes missing UTF-8 support in the group_by for routes.

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

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-11-24 11:26:39 +00:00
George Robinson 70bd5dad98
Support UTF-8 label matchers: Use compat package in Alertmanager server (#3567)
* Support UTF-8 label matchers: Use compat package in Alertmanager server

This pull request adds use of the compat package in Alertmanager server that will allow users to switch between the new matchers/parse parser and the old pkg/labels parser. The new matchers/parse parser uses a fallback mechanism where if the input cannot be parsed in the new parser it then attempts to use the old parser. If an input is parsed in the old parser but not the new parser then a warning log is emitted.

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

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-11-24 10:01:40 +00:00
gotjosh b4f7027908
Deprecate and remove api/v1/ (#2970)
* Deprecate and remove api/v1/

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

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2023-11-24 09:06:04 +00:00
George Robinson 16aa996c4f
Support UTF-8 label matchers: Add compat package with feature flag and use in amtool (#3483)
* Add adapter package for parser feature flag

This commit adds the compat package allowing users to switch
between the new matchers/parse parser and the old pkg/labels parser.
The new matchers/parse parser uses a fallback mechanism where if
the input cannot be parsed in the new parser it then attempts to
use the old parser. If an input is parsed in the old parser but
not the new parser, then a warning log is emitted.

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-10-19 12:00:01 +01:00
George Robinson 5a462df83a
Support UTF-8 label matchers: Add more acceptance tests for braces when using amtool (#3523)
* Add tests for PromQL braces when using amtool alert

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

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-09-21 13:57:11 +01:00
George Robinson 5ba9b9c7c3
Add test for PromQL braces when parsing lists of matchers (#3507)
* Add test for PromQL braces when parsing lists of matchers

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

* Use acceptance tests

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

* Add test creating silence with braces

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

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-09-12 17:00:18 +01:00
George Robinson 6ce841ca22
Fix scheme required for webhook url in amtool (#3509)
* Fix scheme required for webhook url in amtool

This commit fixes issue #3505 where amtool would fail with
"error: scheme required for webhook url" when using amtool
with --alertmanager.url.

The issue here is that UnmarshalYaml for WebhookConfig checks
if the scheme is present when c.URL is non-nil. However,
UnmarshalYaml for SecretURL returns a non-nil, default value
url.URL{} if the response from api/v2/status contains <secret>
as the webhook URL.

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

* Add test for config routes test

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

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-09-05 17:53:24 +01:00
Rohan Gupta df1dc0d359 Changes receiver and inhibition rules arrays to slices of value items
Signed-off-by: Rohan Gupta <rohangupta.0927@gmail.com>
2023-01-18 10:21:51 -05:00
Simon Pasquier 01e1f5433a test: reduce flakiness of acceptance tests
The CI environment isn't as performant as local machines: the time
needed to fully initialize the test environment can be significant and
skew the verification. Rather than setting the "virtual" clock used to
measure alert timings at the beginning of the acceptance test, it is
better to wait for the test bed to be ready.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2023-01-13 16:10:38 +01: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
Cosrider 228b7959b3
Delete unreachable code caused by t.Fatalf (#3042)
Signed-off-by: Cosrider <cosrider7@gmail.com>

Signed-off-by: Cosrider <cosrider7@gmail.com>
2022-09-09 16:07:53 +02:00
inosato 791e542100 Remove ioutil
Signed-off-by: inosato <si17_21@yahoo.co.jp>
2022-07-18 22:01:02 +09:00
gotjosh cbc94fad46
Acceptance Tests: Better error messages
The CI keeps reporting flakes for our acceptance test around the starting and stopping of the Alertmanagers. While I have an idea of where these failures are coming from, it would be nice to get a confirmation by structuring our error messages a bit better.

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-07-07 11:09:42 +01:00
gotjosh ef786ea402
Force close mock servers as part of v2 acceptance tests
While merging #2944, I noticed the CI failed: https://app.circleci.com/pipelines/github/prometheus/alertmanager/2686/workflows/b6f87b0a-20c3-455b-b706-432c38a77511/jobs/12028.

It seemed like a deadlock between uncoordinated routines but I couldn't pin point (or reproduce, I tried with -race and -count) the exact problem. However, from the logs, I could point out where the problem originated and kind of have a hunch it had to do with the way net listeners are handled by the TODO removed.

The more worrying bit of the CI failure is that it took 10m to timeout, with this change we'll force close the connection with a 5s deadline so at the very least we'll get the feedback faster.

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-06-17 12:43:43 +01: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
sinkingpoint e2a10119aa Move api v1 client into v1 tests
This commit moves the stuff formerly in /client into /test/with_api_v1
so that we can discourage use of the v1 client without breaking things

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
2021-11-16 09:36:07 +01:00
QuentinBisson 4aea4560ce
Fix flapping acceptance test
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
2021-04-28 15:04:37 +02:00
Ben Kochie 53535551f5
Fix up golangci-lint errors.
Signed-off-by: Ben Kochie <superq@gmail.com>
2021-03-16 10:43:45 +01:00
Kiril Vladimirov 7320d83cbc Replace types.Matcher(s)? with labels.Matcher(s)?
Signed-off-by: Kiril Vladimirov <kiril@vladimiroff.org>
2021-01-22 17:02:48 +02:00
Josh Soref 0f2c65d265 Spelling (#2167)
* spelling: inhibition

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: matchers

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: notification

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: nonexistent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: obfuscated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurred

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: relevant

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unexpected

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: marshaled

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: marshaling

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-01-23 17:06:16 +01:00
Ilya Gladyshev 196c62f488 At least one non-empty silence matcher (#2081)
* check if at least one silence matcher doesn't match empty strings

Signed-off-by: qoops <ilya.v.gladyshev@gmail.com>

* fixed grammar

Signed-off-by: qoops <ilya.v.gladyshev@gmail.com>
2019-10-31 15:42:03 +01:00
stuart nelson a74758e4c7
Merge pull request #1830 from pgier/amtool-tests
test/cli: add basic amtool cli tests
2019-07-24 17:41:10 +02:00
Paul Gier 588e1e3f9f test/cli: add periods to comment sentences and import ordering
Signed-off-by: Paul Gier <pgier@redhat.com>
2019-06-20 10:37:59 -05:00
Simon Pasquier 1207b90029 test/with_api_v2: remove calls to the v1 API
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-06-20 17:37:08 +02:00
Paul Gier 50ad3114a0 test/cli: add basic tests for amtool cli
Signed-off-by: Paul Gier <pgier@redhat.com>
2019-06-19 17:33:35 -05: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
Simon Pasquier c20873b1fe
test/with_api_v2: fix variable shadowing (#1889)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-05-15 10:49:59 +02:00
stuart nelson 6749f9faa9
Merge pull request #1871 from johncming/hotfix/dup-close
test/with_api_v1: delete duplicate close of http body.
2019-05-06 12:41:29 +02:00
johncming 1c38a90eeb test/with_api_v1: delete duplicate close of http body.
Signed-off-by: johncming <johncming@yahoo.com>
2019-05-05 08:40:18 +08:00
stuart nelson 1cc6c6f79c Move alert endpoints filter parsing to single function
They are exactly the same, no reason to duplicate.

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2019-04-30 10:59:17 +02:00
Paul Gier 8688c7b9ad api/v2: move generated client code from test to api/v2 (#1792)
- Move the generated api/v2 client code out of the test directory
and into the api/v2 directory with models and restapi.
- Remove duplicate models directory
- Update tests to use api/v2 package for models and client

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-12 17:11:23 +01:00
Karsten Weiss c637ca1a6e Fix typos in comments and metric HELPs (#1790)
No functional change.

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2019-03-12 10:29:26 +01:00
Paul Gier 458f1d646b Makefile improvements
- make clean shouldn't print errors when files/directories have already
been removed
- add copyright header to generated api files to pass license check

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-11 10:45:45 -05:00
Simon Pasquier bc373f562f *: fix filter parameters with comma
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-03-08 09:56:05 +01:00
Simon Pasquier c7de536129
*: use stdlib context (#1768)
This changes removes all usage of golang.org/x/net/context in the code
base. It also bumps a few dependencies for the same reason:
- github.com/gogo/protobuf
- go-openapi/*

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-02-26 12:18:57 +01:00
stuart nelson 51eebbef85
Stn/correctly mark api silences (#1733)
* Update alert status on every GET to alerts

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2019-02-18 17:06:51 +01:00
Max Leonard Inden 8e157b3af5
api/v2: Make cluster status peers and name optional
If a users chooses to disable the Alertmanager cluster feature, there is
no cluster name nor cluster peers. Hence these should be optional. Only
cluster status is set to "disabled".

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2019-02-04 11:40:30 +01:00
Max Leonard Inden 2f055d9966
api/v2: Do not populate cluster info if clustering is disabled
When users start Alertmanager with `--cluster.listen-address=`, the
cluster will not be initialized, hence api.peer will be `nil`. So far
this would result in a nil pointer dereference by the API v2 accessing
the api.peer field.

With this patch, api v2 skips populating the peers array, sets the name
to an empty string and the status to "disabled" in case `api.peer` is
nil.

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2019-01-31 16:56:59 +01:00
Simon Pasquier b676fa79c0 *: update Makefile.common with new staticcheck (#1692)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-01-04 15:37:33 +01:00
Max Leonard Inden 2b697aaa6b
api/v2: Extract shared properties of gettable and postable alert
With issue 1465 on openapi-generator [1] being fixed, we can not extract
shared properties of the gettable and postable alert definition into a
shared object (`alert`) like we do for silence, gettable silence and
postable silence.

In addition this patch does the following changes to the UI:

- Use `List GettableAlert` instead of plural type definition like
`GettableAlerts` because the plural definitions are not generated.

- Fix openapi-generator-cli docker image to specific hash.

[1] https://github.com/OpenAPITools/openapi-generator/issues/1465

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-11-28 14:35:39 +01:00
Max Inden 091a8a83b1
Merge pull request #1632 from mxinden/alerts-api-v2
ui: Move alerts to api v2
2018-11-26 14:28:13 +01:00
Simon Pasquier 5fd944a603 test/with_api_v1: add test for route prefix
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-11-23 13:59:28 +01:00
Simon Pasquier d6f8437b9b test/with_api_v2: add test for route prefix
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-11-23 13:59:28 +01:00
Max Leonard Inden f504f953c1
ui: Move /alerts to API v2
Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-11-23 12:53:48 +01:00
Max Inden 573389a9bb
Merge pull request #1623 from simonpasquier/add-test-apiv2
test: add acceptance test for firing alerts with EndsAt
2018-11-18 16:32:59 +01:00
Simon Pasquier 2ea37af92c test: add acceptance test for firing alerts with EndsAt
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-11-15 16:37:41 +01:00