How to learn PromQL with Prometheus Playground
Working with real metrics is hard. Metrics are needed to give you an understanding of how your service behaves. That is, by definition, you have some uncertainty about the said behavior. Therefore, you have to be hell certain about your observability part. Otherwise, all sorts of metric misinterpretations and false conclusions will follow.
Here are the things I'm always trying to get confident about as soon as possible:
- How metric collection works - push vs. pull model, aggregation on the client- or server-side?
- How metrics are stored - raw samples or aggregated data, rollup and retention strategies?
- How to query metrics - is my mental model aligned with the actual query execution model?
- How to plot query results - what approximation errors may be induced by the graphing tools?
And even if I have a solid understanding of all of the above stuff, there will be one thing I'm never entirely sure about - the correctness of my query logic. But this one becomes testable once other parts are known.
Recently, I've been through another round of this journey - I was making an acquaintance with Prometheus. Since it was already a third of fourth monitoring system I had to work with, at first, I thought I could skip all the said steps and jump into writing queries to production metrics and reading graphs... The hope was on the knowledge extrapolation. But nope, it didn't work out well. So, I gave up on the idea of cutting corners quickly. That's how I found myself setting up a Prometheus playground, feeding it with some known inputs, observing the outputs, and trying to draw some meaningful conclusion.