cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/promql/vector_matching.md
128lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # promql/vector_matching |
| 8 | |
| 9 | This check will try to find queries that try to |
| 10 | [match vectors](https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching) |
| 11 | but have different sets of labels on both side of the query. |
| 12 | |
| 13 | Consider these two time series: |
| 14 | |
| 15 | ```js |
| 16 | http_errors{job="node-exporter", cluster="prod", instance="server1"} |
| 17 | ``` |
| 18 | |
| 19 | and |
| 20 | |
| 21 | ```js |
| 22 | cluster:http_errors{job="node-exporter", cluster="prod"} |
| 23 | ``` |
| 24 | |
| 25 | One of them tracks specific instance and one aggregates series for the whole cluster. |
| 26 | Because they have different set of labels if we want to calculate some value using both |
| 27 | of them, for example: |
| 28 | |
| 29 | ```js |
| 30 | http_errors / cluster:http_errors |
| 31 | ``` |
| 32 | |
| 33 | we wouldn't get any results. To fix that we need ignore extra labels: |
| 34 | |
| 35 | ```js |
| 36 | http_errors / ignoring(instance) cluster:http_errors |
| 37 | ``` |
| 38 | |
| 39 | This check aims to find all queries that using vector matching where both sides |
| 40 | of the query have different sets of labels causing no results to be returned. |
| 41 | |
| 42 | **NOTE**: it's impossible for this check to inspect all time series in Prometheus |
| 43 | against all other series as it would be too expensive. |
| 44 | It will first check if given query returns anything, and |
| 45 | only if it doesn't it will run extra checks. When running extra checks it will sample |
| 46 | only a few time series from each side of the query, so it might not find all possible |
| 47 | issues. |
| 48 | |
| 49 | ## Configuration |
| 50 | |
| 51 | This check doesn't have any configuration options. |
| 52 | |
| 53 | ## How to enable it |
| 54 | |
| 55 | This check is enabled by default for all configured Prometheus servers. |
| 56 | |
| 57 | Example: |
| 58 | |
| 59 | ```js |
| 60 | prometheus "prod" { |
| 61 | uri = "https://prometheus-prod.example.com" |
| 62 | timeout = "60s" |
| 63 | include = [ |
| 64 | "rules/prod/.*", |
| 65 | "rules/common/.*", |
| 66 | ] |
| 67 | } |
| 68 | |
| 69 | prometheus "dev" { |
| 70 | uri = "https://prometheus-dev.example.com" |
| 71 | timeout = "30s" |
| 72 | include = [ |
| 73 | "rules/dev/.*", |
| 74 | "rules/common/.*", |
| 75 | ] |
| 76 | } |
| 77 | ``` |
| 78 | |
| 79 | ## How to disable it |
| 80 | |
| 81 | You can disable this check globally by adding this config block: |
| 82 | |
| 83 | ```js |
| 84 | checks { |
| 85 | disabled = ["promql/vector_matching"] |
| 86 | } |
| 87 | ``` |
| 88 | |
| 89 | You can also disable it for all rules inside given file by adding |
| 90 | a comment anywhere in that file. Example: |
| 91 | |
| 92 | ```yaml |
| 93 | # pint file/disable promql/vector_matching |
| 94 | ``` |
| 95 | |
| 96 | Or you can disable it per rule by adding a comment to it. Example: |
| 97 | |
| 98 | ```yaml |
| 99 | # pint disable promql/vector_matching |
| 100 | ``` |
| 101 | |
| 102 | If you want to disable only individual instances of this check |
| 103 | you can add a more specific comment. |
| 104 | |
| 105 | ```yaml |
| 106 | # pint disable promql/vector_matching($prometheus) |
| 107 | ``` |
| 108 | |
| 109 | Where `$prometheus` is the name of Prometheus server to disable. |
| 110 | |
| 111 | Example: |
| 112 | |
| 113 | ```yaml |
| 114 | # pint disable promql/vector_matching(prod) |
| 115 | ``` |
| 116 | |
| 117 | ## How to snooze it |
| 118 | |
| 119 | You can disable this check until given time by adding a comment to it. Example: |
| 120 | |
| 121 | ```yaml |
| 122 | # pint snooze $TIMESTAMP promql/vector_matching |
| 123 | ``` |
| 124 | |
| 125 | Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) |
| 126 | formatted or `YYYY-MM-DD`. |
| 127 | Adding this comment will disable `promql/vector_matching` *until* `$TIMESTAMP`, after that |
| 128 | check will be re-enabled. |
| 129 | |