promtool(1)
Validate and test Prometheus configuration files, rules, and alert templates.
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
| Flag | What it does |
|---|---|
config.file | Path to the Prometheus configuration file to validate |
--alertmanager.config | Path to the Alertmanager configuration file to validate |
--lint=all | Perform additional linting checks (all, duplicate-rules, none) |
--check-rules | Check specified rule files for syntax errors and duplicates |
--test.rules | Test alerting/recording rules against sample data |
--template.glob | Glob pattern for alert template files to validate |
--duration | How long to evaluate rules for (used with test.rules) |
--quiet | Suppress output on successful validation |
Examples
Validate the Prometheus configuration file for syntax errors
promtool check config prometheus.ymlCheck all rule files in a directory for syntax and duplicate detection
promtool check rules /etc/prometheus/rules/*.ymlTest alerting rules using a test file with sample metric data
promtool test rules test.ymlValidate config file with all additional linting checks enabled
promtool check config --lint=all prometheus.ymlValidate Alertmanager configuration file syntax
promtool check alerts alertmanager.ymlExecute an instant query (requires running Prometheus server)
promtool query instant 'up' --query-results=5