PromQL vector matching: what it is and how it affects your Prometheus queries
Blog post from Grafana Labs
PromQL vector matching is a crucial concept in Prometheus queries, which often involves handling vectors—a collection of time series data points that can be instant or range vectors, and may include labels. Dawid Dębowski, a software engineer, explains how arithmetic operations between vectors can result in unexpected outcomes, such as receiving a "No data" response, due to mismatches in vector labels. He illustrates this with an example of calculating the percentage of water-type Pokémons caught, highlighting that Prometheus compares labels on vectors for operations, dropping unmatched vectors. Solutions to ensure accurate results include using the same labels on both vectors or leveraging PromQL keywords like on and ignoring to guide Prometheus in matching vectors with different label sets. Additionally, the post touches on advanced techniques such as group_left and group_right for handling many-to-one vector matching scenarios, emphasizing the importance of understanding vector matching for accurate query results in real-world applications.