Using recording rules

Rules are defined separately from the main Prometheus configuration file, and are included by the latter through the rule_files top-level configuration key. They are evaluated periodically, and that interval can be defined globally with evaluation_interval inside global (defaults to one minute).

We can see this by looking at the configuration provided with the test environment:

vagrant@prometheus:~$ cat /etc/prometheus/prometheus.ymlglobal:...  evaluation_interval: 1m...rule_files:  - "recording_rules.yml"...

rule_files takes a list of paths, which can be relative to the main Prometheus configuration or absolute paths. Additionally, globs can be used to match filenames (not directories); for example, /etc/prometheus/rules/*.yml ...

Get Hands-On Infrastructure Monitoring with Prometheus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.