From b2851b150d33ffad3dff8ed131b8a907521d1764 Mon Sep 17 00:00:00 2001 From: Harold Dost Date: Tue, 17 May 2022 16:03:18 +0200 Subject: [PATCH] docs: Add subsections for vector matching * Provide a callout about the vector matching keywords and the group modifiers. Relates prometheus/docs#2106 Signed-off-by: Harold Dost --- docs/querying/operators.md | 43 +++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/docs/querying/operators.md b/docs/querying/operators.md index 9f35e0c15..9c1249b46 100644 --- a/docs/querying/operators.md +++ b/docs/querying/operators.md @@ -114,6 +114,37 @@ Operations between vectors attempt to find a matching element in the right-hand vector for each entry in the left-hand side. There are two basic types of matching behavior: One-to-one and many-to-one/one-to-many. +### Vector matching keywords + +These vector matching keywords allow for matching between series with different label sets +providing: + +* `on` +* `ignoring` + +Label lists provided to matching keywords will determine how vectors are combined. Examples +can be found in [One-to-one vector matches](#one-to-one-vector-matches) and in +[Many-to-one and one-to-many vector matches](#many-to-one-and-one-to-many-vector-matches) + +### Group modifiers + +These group modifiers enable many-to-one/one-to-many vector matching: + +* `group_left` +* `group_right` + +Label lists can be provided to the group modifier which contain labels from the "one"-side to +be included in the result metrics. + +_Many-to-one and one-to-many matching are advanced use cases that should be carefully considered. +Often a proper use of `ignoring()` provides the desired outcome._ + +_Grouping modifiers can only be used for +[comparison](#comparison-binary-operators) and +[arithmetic](#arithmetic-binary-operators). Operations as `and`, `unless` and +`or` operations match with all possible entries in the right vector by +default._ + ### One-to-one vector matches **One-to-one** finds a unique pair of entries from each side of the operation. @@ -153,7 +184,7 @@ The entries with methods `put` and `del` have no match and will not show up in t **Many-to-one** and **one-to-many** matchings refer to the case where each vector element on the "one"-side can match with multiple elements on the "many"-side. This has to -be explicitly requested using the `group_left` or `group_right` modifier, where +be explicitly requested using the `group_left` or `group_right` [modifiers](#group-modifiers), where left/right determines which vector has the higher cardinality. ignoring(