In Chapter 8, Troubleshooting and Validation, we went through the features that promtool has to offer, with the exception of testing. The test rules subcommand can simulate the periodic ingestion of samples for several time series, use those series to evaluate recording and alerting rules, and then test whether the recorded series match what was configured as the expected results. Now that we understand recording and alerting rules, we'll look at how to ensure that they behave as expected, by creating unit tests and using promtool to validate our rules.
Testing your rules
Recording rules tests
The promtool tool included in the Prometheus binary distribution allows us to define test cases to validate that the rules we...