Understanding the Prometheus Query Language
As we've seen in the previous parts of this chapter, Prometheus provides its own query language called PromQL. It allows you to search, view, and aggregate the time-series data stored in the Prometheus database. This section helps you understand the query language further. There are four core metric types in Prometheus, and we will start by describing each.
Counter
A counter counts elements over time; for example, this could be the number of visits to your website. The count will only go up or it will reset when a service or application is restarted. They are suited to counting the number of certain events at a point in time. Each time the counter changes, the number will also be reflected in the data you collect.
Counters usually end with the _total
suffix. But due to the nature of counters, each time a service is restarted, the counter will be set back to 0. Using the rate()
or irate()
functions in our query, we will be able...