* 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>
* 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>
* 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>
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>
* 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>
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>
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>
* 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>
* 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>
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>
* 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>