$linuxjunkies
>

promtool(1)

Validate and test Prometheus configuration files, rules, and alert templates.

UbuntuDebianFedoraArch

Synopsis

promtool [COMMAND] [OPTIONS]

Description

promtool is a command-line utility for working with Prometheus configuration and rules. It validates YAML syntax, checks rule correctness, tests alerting rules, and performs template rendering without requiring a running Prometheus server.

Common operations include validating prometheus.yml config files, checking recording and alerting rules for errors, testing alert templates with sample data, and converting unit formats. It's essential for CI/CD pipelines and configuration management.

Common options

FlagWhat it does
config.filePath to the Prometheus configuration file to validate
--alertmanager.configPath to the Alertmanager configuration file to validate
--lint=allPerform additional linting checks (all, duplicate-rules, none)
--check-rulesCheck specified rule files for syntax errors and duplicates
--test.rulesTest alerting/recording rules against sample data
--template.globGlob pattern for alert template files to validate
--durationHow long to evaluate rules for (used with test.rules)
--quietSuppress output on successful validation

Examples

Validate the Prometheus configuration file for syntax errors

promtool check config prometheus.yml

Check all rule files in a directory for syntax and duplicate detection

promtool check rules /etc/prometheus/rules/*.yml

Test alerting rules using a test file with sample metric data

promtool test rules test.yml

Validate config file with all additional linting checks enabled

promtool check config --lint=all prometheus.yml

Validate Alertmanager configuration file syntax

promtool check alerts alertmanager.yml

Execute an instant query (requires running Prometheus server)

promtool query instant 'up' --query-results=5

Related commands