.TH AMTOOL "1" "March 2024" "prometheus-alertmanager 0.27.0+ds" "Prometheus"/ .SH "NAME" amtool \- Tooling for the Prometheus alert manager .SH "SYNOPSIS" .TP \fBamtool [] [ ...]\fR .SH "DESCRIPTION" View and modify the current Alertmanager state. Config File: The alertmanager tool will read a config file in YAML format from one of two default config locations: $HOME/.config/prometheus/amtool.yml or /etc/prometheus/amtool.yml All flags can be given in the config file, but the following are the suited for static configuration: alertmanager.url Set a default alertmanager url for each request author Set a default author value for new silences. If this argument is not specified then the username will be used require-comment Bool, whether to require a comment on silence creation. Defaults to true output Set a default output type. Options are (simple, extended, json) date.format Sets the output format for dates. Defaults to "2006-01-02 15:04:05 MST" http.config.file HTTP client configuration file for amtool to connect to Alertmanager. The format is https://prometheus.io/docs/alerting/latest/configuration/#http_config. .SH "OPTIONS" .TP \fB-h, --help\fR Show context-sensitive help (also try --help-long and --help-man). .TP \fB--date.format\fR Format of date output .TP \fB-v, --verbose\fR Verbose running information .TP \fB--alertmanager.url=http://localhost:9093/\fR Alertmanager to talk to .TP \fB-o, --output=simple\fR Output formatter (simple, extended, json) .TP \fB--timeout=30s\fR Timeout for the executed command .TP \fB--http.config.file=\fR HTTP client configuration file for amtool to connect to Alertmanager. .TP \fB--version-check\fR Check alertmanager version. Use --no-version-check to disable. .TP \fB--enable-feature\fR Experimental features to enable. The flag can be repeated to enable multiple features. Valid options: receiver-name-in-metrics, classic-mode, utf8-strict-mode .TP \fB--version\fR Show application version. .SH "COMMANDS" .SS \fBhelp [...]\fR .PP Show help. .SS \fBalert query [] [...]\fR .PP View and search through current alerts. Amtool has a simplified prometheus query syntax, but contains robust support for bash variable expansions. The non-option section of arguments constructs a list of "Matcher Groups" that will be used to filter your query. The following examples will attempt to show this behaviour in action: amtool alert query alertname=foo node=bar This query will match all alerts with the alertname=foo and node=bar label value pairs set. amtool alert query foo node=bar If alertname is omitted and the first argument does not contain a '=' or a '=~' then it will be assumed to be the value of the alertname pair. amtool alert query 'alertname=~foo.*' As well as direct equality, regex matching is also supported. The '=~' syntax (similar to prometheus) is used to represent a regex match. Regex matching can be used in combination with a direct match. Amtool supports several flags for filtering the returned alerts by state (inhibited, silenced, active, unprocessed). If none of these flags is given, only active alerts are returned. .TP \fB-i, --inhibited\fR Show inhibited alerts .TP \fB-s, --silenced\fR Show silenced alerts .TP \fB-a, --active\fR Show active alerts .TP \fB-u, --unprocessed\fR Show unprocessed alerts .TP \fB-r, --receiver=RECEIVER\fR Show alerts matching receiver (Supports regex syntax) .SS \fBalert add [] [...]\fR .PP Add a new alert. This command is used to add a new alert to Alertmanager. To add a new alert with labels: amtool alert add alertname=foo node=bar If alertname is omitted and the first argument does not contain a '=' then it will be assumed to be the value of the alertname pair. amtool alert add foo node=bar One or more annotations can be added using the --annotation flag: amtool alert add foo node=bar \ --annotation=runbook='http://runbook.biz' \ --annotation=summary='summary of the alert' \ --annotation=description='description of the alert' Additional flags such as --generator-url, --start, and --end are also supported. .TP \fB--generator-url=GENERATOR-URL\fR Set the URL of the source that generated the alert .TP \fB--start=START\fR Set when the alert should start. RFC3339 format 2006-01-02T15:04:05-07:00 .TP \fB--end=END\fR Set when the alert should should end. RFC3339 format 2006-01-02T15:04:05-07:00 .TP \fB--annotation=ANNOTATION\fR Set an annotation to be included with the alert .SS \fBsilence add [] [...]\fR .PP Add a new alertmanager silence This statement will add a silence that matches alerts with the alertname=foo and node=bar label value pairs set. If alertname is omitted and the first argument does not contain a '=' or a '=~' then it will be assumed to be the value of the alertname pair. As well as direct equality, regex matching is also supported. The '=~' syntax (similar to Prometheus) is used to represent a regex match. Regex matching can be used in combination with a direct match. .TP \fB-a, --author=AUTHOR\fR Username for CreatedBy field .TP \fB-d, --duration="1h"\fR Duration of silence .TP \fB--start=START\fR Set when the silence should start. RFC3339 format 2006-01-02T15:04:05-07:00 .TP \fB--end=END\fR Set when the silence should end (overwrites duration). RFC3339 format 2006-01-02T15:04:05-07:00 .TP \fB-c, --comment=COMMENT\fR A comment to help describe the silence .SS \fBsilence expire [...]\fR .PP expire an alertmanager silence .SS \fBsilence import [] []\fR .PP Import alertmanager silences from JSON file or stdin This command can be used to bulk import silences from a JSON file created by query command. For example: amtool silence query -o json foo > foo.json amtool silence import foo.json JSON data can also come from stdin if no param is specified. .TP \fB-f, --force\fR Force adding new silences even if it already exists .TP \fB-w, --worker=8\fR Number of concurrent workers to use for import .SS \fBsilence query [] [...]\fR .PP Query Alertmanager silences. Amtool has a simplified prometheus query syntax, but contains robust support for bash variable expansions. The non-option section of arguments constructs a list of "Matcher Groups" that will be used to filter your query. The following examples will attempt to show this behaviour in action: amtool silence query alertname=foo node=bar This query will match all silences with the alertname=foo and node=bar label value pairs set. amtool silence query foo node=bar If alertname is omitted and the first argument does not contain a '=' or a '=~' then it will be assumed to be the value of the alertname pair. amtool silence query 'alertname=~foo.*' As well as direct equality, regex matching is also supported. The '=~' syntax (similar to prometheus) is used to represent a regex match. Regex matching can be used in combination with a direct match. In addition to filtering by silence labels, one can also query for silences that are due to expire soon with the "--within" parameter. In the event that you want to preemptively act upon expiring silences by either fixing them or extending them. For example: amtool silence query --within 8h returns all the silences due to expire within the next 8 hours. This syntax can also be combined with the label based filtering above for more flexibility. The "--expired" parameter returns only expired silences. Used in combination with "--within=TIME", amtool returns the silences that expired within the preceding duration. amtool silence query --within 2h --expired returns all silences that expired within the preceding 2 hours. .TP \fB--expired\fR Show expired silences instead of active .TP \fB-q, --quiet\fR Only show silence ids .TP \fB--created-by=CREATED-BY\fR Show silences that belong to this creator .TP \fB--id=ID\fR Get a single silence by its ID .TP \fB--within=WITHIN\fR Show silences that will expire or have expired within a duration .SS \fBsilence update [] [...]\fR .PP Update silences .TP \fB-q, --quiet\fR Only show silence ids .TP \fB-d, --duration=DURATION\fR Duration of silence .TP \fB--start=START\fR Set when the silence should start. RFC3339 format 2006-01-02T15:04:05-07:00 .TP \fB--end=END\fR Set when the silence should end (overwrites duration). RFC3339 format 2006-01-02T15:04:05-07:00 .TP \fB-c, --comment=COMMENT\fR A comment to help describe the silence .SS \fBcheck-config [...]\fR .PP Validate alertmanager config files Will validate the syntax and schema for alertmanager config file and associated templates. Non existing templates will not trigger errors. .SS \fBcluster show\fR .PP View cluster status and peers. .SS \fBconfig show\fR .PP View current config. The amount of output is controlled by the output selection flag: - Simple: Print just the running config - Extended: Print the running config as well as uptime and all version info - Json: Print entire config object as json .SS \fBconfig routes show\fR .PP Prints alert routing tree Will print whole routing tree in form of ASCII tree view. Routing is loaded from a local configuration file or a running Alertmanager configuration. Specifying --config.file takes precedence over --alertmanager.url. Example: amtool config routes [show] --config.file=doc/examples/simple.yml .SS \fBconfig routes test [] [...]\fR .PP Test alert routing Will return receiver names which the alert with given labels resolves to. If the labelset resolves to multiple receivers, they are printed out in order as defined in the routing tree. Routing is loaded from a local configuration file or a running Alertmanager configuration. Specifying --config.file takes precedence over --alertmanager.url. Example: amtool config routes test --config.file=doc/examples/simple.yml --verify.receivers=team-DB-pager service=database .TP \fB--verify.receivers=VERIFY.RECEIVERS\fR Checks if specified receivers matches resolved receivers. The command fails if the labelset does not route to the specified receivers. .TP \fB--tree\fR Prints out matching routes tree. .SS \fBtemplate render --template.glob=TEMPLATE.GLOB --template.text=TEMPLATE.TEXT []\fR .PP Render a given definition in a template file to standard output. .TP \fB--template.glob=TEMPLATE.GLOB\fR Glob of paths that will be expanded and used for rendering. .TP \fB--template.text=TEMPLATE.TEXT\fR The template that will be rendered. .TP \fB--template.type=TEMPLATE.TYPE\fR The type of the template. Can be either text (default) or html. .TP \fB--template.data=TEMPLATE.DATA\fR Full path to a file which contains the data of the alert(-s) with which the --template.text will be rendered. Must be in JSON. File must be formatted according to the following layout: https://pkg.go.dev/github.com/prometheus/alertmanager/template#Data. If none has been specified then a predefined, simple alert will be used for rendering.