LinuxCommandLibrary

promtool

Validate and test Prometheus configuration files

TLDR

Check if the configuration files are valid or not (if present report errors)

$ promtool check config [config_file.yml]
copy

Check if the rule files are valid or not (if present report errors)
$ promtool check rules [rules_file.yml]
copy

Pass Prometheus metrics over stdin to check them for consistency and correctness
$ curl --silent [http://example.com:9090/metrics/] | promtool check metrics
copy

Unit tests for rules config
$ promtool test rules [test_file.yml]
copy

SYNOPSIS

promtool [flags] [command flags]

PARAMETERS

--config.file=
    Path to the Prometheus configuration file to validate.

--rule.files=...
    Paths to the Prometheus rule files to validate.

check config
    Validate the Prometheus configuration file.

check rules
    Validate the Prometheus rule files.

query
    Execute a Prometheus query and print the results.

debug web-config
    Inspect the web configuration of a running Prometheus server.

DESCRIPTION

Promtool is a command-line utility designed to aid in configuring, testing, and debugging Prometheus monitoring setups.

It provides functionalities for validating Prometheus configuration files, alerting rules, and recording rules.

Furthermore, promtool allows users to execute queries against a local or remote Prometheus instance to test their correctness, as well as inspect and debug the configuration of running Prometheus servers.

By utilizing promtool, users can proactively identify and resolve issues, ensuring the reliability and accuracy of their Prometheus-based monitoring systems.

EXIT CODES

Promtool returns an exit code of 0 on success and a non-zero exit code on failure. Use the exit code to check that command works as expected.

For instance, checking the configuration file that has error will result in a non-zero exit code.

The errors can be seen from the output.

EXAMPLE

The following command checks if the prometheus.yml configuration file has errors:

promtool check config prometheus.yml

HISTORY

Promtool has evolved as an essential part of the Prometheus ecosystem, providing vital tools for users and developers to confirm the validity and correctness of their monitoring setup. Over time, additional features for query execution, remote server inspection, and more were added making it an important tool for operating and maintaining Prometheus instances.

SEE ALSO

prometheus(1)

Copied to clipboard