Commit Graph

101 Commits

Author SHA1 Message Date
George Robinson
848e2191d9
Support UTF-8 label matchers: Add metrics to matchers compat package (#3658)
* Add metrics to matchers compat package

This commit adds the following metrics to the compat package:

  alertmanager_matchers_parse
  alertmanager_matchers_disagree
  alertmanager_matchers_incompatible
  alertmanager_matchers_invalid

With a label called origin to differentiate the different sources
of inputs: the configuration file, the API, and amtool.

The disagree_total metric is incremented when an input is invalid
in both parsers, but results in different parsed representations,
then there is disagreement. This should not happen, and suggests
their is either a bug in one of the parsers or a mistake in the
backwards compatible guarantees of the matchers/parse parser.

The incompatible_total metric is incremented when an input is valid
in pkg/labels, but not the UTF-8 parser in matchers/parse. In such
case, the matcher should be updated to be compatible. This often
means adding double quotes around the right hand side of the matcher.
For example, foo="bar".

The invalid_total metric is incremented when an input is invalid
in both parsers. This was never a valid input.

The tests have been updated to check the metrics are incremented
as expected.

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

---------

Signed-off-by: George Robinson <george.robinson@grafana.com>
2024-01-05 10:21:20 +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
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
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
c6be0bcabf
Remove unused function GetAlertmanagerURL (#3535)
Signed-off-by: George Robinson <george.robinson@grafana.com>
2023-09-25 11:11:56 +01:00
Manuel Rüger
f2f411094e Update gopkg.in/alecthomas/kingpin.v2 to github.com/alecthomas/kingpin/v2
Upstream changed package name, see:
https://github.com/alecthomas/kingpin#overview

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2023-03-08 15:02:24 +01:00
Colin Douch
a66692fa56
Add --id flag to amtool silence query (#3241)
In the Web UI, we have a UI to get information on a given silence
through its ID. This functionality is missing from amtool however,
leading to the necessity to pull _all_ the silenced, and filter with
`grep` or similar.

This commit adds in a `--id` flag to the `silence query` command, which
allows specifying an ID to match on, matching the functionality of the Web UI.

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
2023-02-22 11:50:25 +00:00
Martin Chodur
26cbd6bd86
feat: add template.FromGlobsWithAdditionalFuncs (#3174)
* refactor: add Options to the template.FromGlob function to allow customizing the Template

Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
2022-12-16 10:13:13 -04:00
Martin Chodur
95fcc8b192 feat: switch to LoadHTTPConfigFile from common
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
2022-12-09 12:01:51 +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
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
Chunlin Yang
ef25f81f1b
amtool to support http_config to access alertmanager (#2764)
* Support http_config for amtool

Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: clyang82 <chuyang@redhat.com>
2022-01-19 10:01:58 +01:00
Simon Pasquier
48a99764a1
*: bump to Go 1.17 (#2792)
* *: bump to Go 1.17

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

* *: fix yamllint errors

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2021-12-22 14:03:53 +01:00
Joe Groocock
4fcbeeca9e Add client TLS configuration
Allows connecting to alertmanager instances behind a TLS endpoint that
requires mutual TLS. Conveniently also allows specifying a CA
certificate file for alertmanagers that use trusted roots not in the
system root trust store.

Fixes: https://github.com/prometheus/alertmanager/issues/2652
Signed-off-by: Joe Groocock <me@frebib.net>
2021-11-16 09:35:09 +01:00
Nik Reiman
5b825e22a4
Allow filtering silences by createdBy author (#2718)
This commit adds a `--created-by` argument to the `amtool silence
query` command so that silences can be filtered by the author they
were created with in `amtool silence add --author=<name>`.

Signed-off-by: nre <nre@ableton.com>
2021-11-09 13:10:19 +01:00
Takuma Ishikawa
5ddf9e24ea
amtool: Fix behavior of adding silence with duration option (#2741)
endsAt should be calculated from startsAt, not from the current time

Signed-off-by: nekketsuuu <nekketsuuu@users.noreply.github.com>
2021-10-18 15:13:42 +02:00
Julien Pivotto
f684896d85
amtool: Detect version drift and warn users (#2672)
* amtool: Detect version drift and warn users

This change detects the alertmanager version when initiating the client.
It ignores most errors since I expect amtool to fail later.

If amtool is not compiled with proper version, we do not do anything
either.

We use MajorMinor for now as we have not reach 1.0, but we still allow
the bugfix version number (Z in x.y.Z) to differ.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Add version check

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-08-09 11:06:09 +02:00
nedvna
c72c4d79f6
Add ability to skip TLS verification for amtool (#2663)
* Add ability to skip TLS verification for amtool

Signed-off-by: Nikita Nedvetskii <72229464+nedvna@users.noreply.github.com>
2021-08-06 11:12:18 +02:00
Julien Pivotto
e21cdfbc52
Fix empty isEqual in amtool. (#2668)
This is the best we can do to make amtool support old releases.

Supersedes #2634
Fix #2666

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-08-06 11:11:16 +02:00
Giedrius Statkevičius
3962da4073
cli: add new template render command (#2538)
* cli: add new template render command

Add a new template rendering command that allows users to test out their
templates. This is especially needed because small bugs in templates do
not surface until alertmanager actually tries to render them.

* cli: permit passing alert data via a file

Add a new parameter `--templatefile` for `amtool` so that it would be
possible to pass custom alert data. Use an example `template.Data` if
none has been passed to permit simple use-cases.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
2021-08-04 13:58:33 +02:00
Goutham Veeramachaneni
e26425473c
Update go-openapi to latest
go-swagger 0.25.0+ are failing though :/

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
2021-03-10 19:00:22 +01:00
ArthurSens
74d388e3f4 Amtool and Alertmanager binaries print to stdout
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
2021-03-04 15:31:17 +00:00
Kiril Vladimirov
84dd6ab8d7 cli/format: Use Matchers.String for extended formatting
Signed-off-by: Kiril Vladimirov <kiril@vladimiroff.org>
2021-02-18 23:43:15 +02:00
Kiril Vladimirov
217562e838 cli/format: Create labels.Matcher to format
There is non-trivial value escaping going inside pkg/labels.

Signed-off-by: Kiril Vladimirov <kiril@vladimiroff.org>
2021-02-18 23:43:15 +02:00
Kiril Vladimirov
f503012c0b cli: Parse properly all matcher types
Signed-off-by: Kiril Vladimirov <kiril@vladimiroff.org>
2021-02-16 14:22:59 +02:00
Kiril Vladimirov
133b5bab42 cli: Unify matcher formatting
Signed-off-by: Kiril Vladimirov <kiril@vladimiroff.org>
2021-02-16 14:22:59 +02:00
treydock
e6824a3110
Fix extended printing of regex sign (#2445)
Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
2021-01-27 11:06:47 +01:00
Atibhi Agrawal
6b36afbbec
Add negative matchers for routing. (#2434)
Add negative route matchers using label.Matcher

Signed-off-by: aSquare14 <atibhi.a@gmail.com>

Signed-off-by: beorn7 <beorn@grafana.com>

Co-authored-by: Björn Rabenstein <beorn@grafana.com>
2021-01-15 21:11:39 +01:00
Koki Kato
042d7b34f0
cli: avoid nil dereference in silence update (#2427)
Signed-off-by: Koki Kato <koki.kato1994@gmail.com>
2020-12-02 17:02:12 +01:00
Fahri YARDIMCI
41cd012c61
Add alert status for extended and simple output (#2324)
Signed-off-by: Fahri Yardımcı <f.yardimci06@gmail.com>
2020-07-24 15:02:58 +02:00
Fahri YARDIMCI
12db463c7f
Add cluster command to show cluster and peer statuses. (#2256)
Signed-off-by: Fahri Yardımcı <f.yardimci06@gmail.com>

Signed-off-by: Fahri Yardımcı <f.yardimci06@gmail.com>
2020-05-18 15:25:15 +02:00
Kevin Hellemun
a2aa0cb5bf [#2160] Removed default assignment of env vars. (#2161)
Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>
2020-01-22 14:53:19 +01:00
Simon Pasquier
e4437ab54f
*: remove dependency on github.com/prometheus/prometheus (#2009)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-09-16 10:56:29 +02:00
johncming
40b3facdf6 config: use the origin field instead of local var (#1999)
Signed-off-by: johncming <johncming@yahoo.com>
2019-08-26 14:01:40 +02:00
Simon Pasquier
add7700a8b
cmd/amtool: use base path from the configured URL (#1940)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-06-25 14:22:29 +02:00
stuart nelson
678ff5cf04 [amtool] print silence id, not silence id's pointer
fixes #1917

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2019-06-10 10:22:49 +02:00
stuart nelson
ac03e5a818 Support filtering cli alert queries by receiver
This was dropped accidentally in
https://github.com/prometheus/alertmanager/pull/1798

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2019-06-07 12:20:38 +02:00
Adam Eijdenberg
e2d8fd1e09 Use scheme and auth info if present from URL
Signed-off-by: Adam Eijdenberg <adam.eijdenberg@digital.gov.au>
2019-05-16 14:29:44 +10:00
Paul Gier
fab3d1e89f cli: remove duplicate import
Signed-off-by: Paul Gier <pgier@redhat.com>
2019-04-02 09:58:01 -05:00
Paul Gier
e31cfbf365 cli: minor style improvements
Signed-off-by: Paul Gier <pgier@redhat.com>
2019-04-01 10:50:38 -05:00
Paul Gier
3b9629e294 cli: check for NotFound error during silence import
Check the error type when there is a non-existent silence
instead of comparing the text of the error message.

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 10:02:39 -05:00
Paul Gier
ab4784b112 cli: style improvement and fix filter handling
Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 09:11:09 -05:00
Paul Gier
6561774f9e cli: fix some command output formatting
- remove brackets around silence ID when adding new silence
- fix simple formatting of show config

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 09:11:09 -05:00
Paul Gier
2d483fac88 minor godoc improvements
Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 09:11:09 -05:00
Paul Gier
74fa2236f7 cli: update amtool to use apiv2
Includes godoc improvements

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 09:11:09 -05:00
xuyasong
60c9bf49c2 fix golint error
Signed-off-by: xuyasong <1154564309@qq.com>
2019-03-15 18:10:36 +08: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
Nguyen Quang Huy
edf170d03b Add signed off to commit (#1766)
- Fix error string should not be capitalized from [Golang coding convention](https://github.com/golang/go/wiki/CodeReviewComments#error-strings)
- Fix some typos

Signed-off-by: Nguyen Quang Huy <huynq0911@gmail.com>
2019-02-25 11:04:42 +01:00
Hrishikesh Barman
dc74b6a15b support for assuming first label is alertname in silence add and query (#1693)
* simplified setting first assumed alertname in cli/silence_query.go
* added assumed first label to alertname when adding silences

Signed-off-by: Hrishikesh Barman <hrishikeshbman@gmail.com>
2019-01-07 13:49:41 +01:00