← 返回命令列表

Linux command

amtool 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List all current alerts

amtool alert

Query alerts matching a label

amtool alert query [alertname="HighMemory"]

Create a silence

amtool silence add [alertname="HighMemory"] --comment="[Maintenance]" --duration=[2h]

List all active silences

amtool silence query

Expire a silence

amtool silence expire [silence_id]

Check Alertmanager configuration

amtool check-config [alertmanager.yml]

Show cluster status

amtool cluster show

说明

amtool is the official command-line client for interacting with Prometheus Alertmanager. It provides capabilities for querying alerts, managing silences, testing routing configurations, and validating configuration files. The tool connects to an Alertmanager instance via its HTTP API to perform operations. It is particularly useful for creating silences during maintenance windows, debugging alert routing, and integrating Alertmanager management into automation scripts. Configuration can be validated offline using check-config without requiring a running Alertmanager instance. The config routes test command helps verify that alerts will be routed to expected receivers based on their labels.

参数

alert
Query and manage alerts.
silence add _matchers_
Create a new silence matching the specified labels.
silence query
List active silences.
silence expire _id_
Remove a silence by its ID.
check-config _file_
Validate an Alertmanager configuration file.
cluster show
Display cluster membership status.
config routes
Display routing tree from configuration.
config routes test _labels_
Test which route matches given labels.
--alertmanager.url _url_
Alertmanager URL (default: http://localhost:9093).
--comment _text_
Comment for a silence (required).
--author _name_
Author of a silence.
--duration _duration_
Duration for a silence (e.g., 1h, 30m).
-o, --output _format_
Output format: simple, extended, json.

FAQ

What is the amtool command used for?

amtool is the official command-line client for interacting with Prometheus Alertmanager. It provides capabilities for querying alerts, managing silences, testing routing configurations, and validating configuration files. The tool connects to an Alertmanager instance via its HTTP API to perform operations. It is particularly useful for creating silences during maintenance windows, debugging alert routing, and integrating Alertmanager management into automation scripts. Configuration can be validated offline using check-config without requiring a running Alertmanager instance. The config routes test command helps verify that alerts will be routed to expected receivers based on their labels.

How do I run a basic amtool example?

Run `amtool alert` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does alert do in amtool?

Query and manage alerts.