cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/promql/range_query.md
105lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # promql/range_query |
| 8 | |
| 9 | This check inspects range query selectors on all queries. |
| 10 | It will warn if a query tries to request a time range that |
| 11 | is bigger than Prometheus retention limits. |
| 12 | |
| 13 | By default Prometheus keeps [15 days of data](https://prometheus.io/docs/prometheus/latest/storage/#operational-aspects), |
| 14 | this can be customized by setting time or disk space limits. |
| 15 | There are two main ways of configuring retention limits in Prometheus: |
| 16 | * time based - Prometheus will keep last N days of metrics |
| 17 | * disk based - Prometheus will try to use up to N bytes of disk space. |
| 18 | |
| 19 | Pint will ignore any disk space limits, since that doesn't tell us |
| 20 | what the effective time retention is. |
| 21 | But it will check the value of `--storage.tsdb.retention.time` flag passed |
| 22 | to Prometheus and it will warn if any selector tries to query more |
| 23 | data then Prometheus can store. |
| 24 | |
| 25 | For example if Prometheus is running with `--storage.tsdb.retention.time=30d` |
| 26 | then it will store up to 30 days of historical metrics data. |
| 27 | If we would try to query `foo[40d]` then that query can only return up |
| 28 | to 30 days of data, it will never return more. |
| 29 | |
| 30 | This usually isn't really a problem but can indicate a mismatch between |
| 31 | expectations of data retention and reality, and so you might think that by |
| 32 | getting results of a `avg_over_time(foo[40d])` you are getting the average |
| 33 | value of `foo` in the last 40 days, but in reality you're only getting |
| 34 | an average value in the last 30 days, and you cannot get any more than that. |
| 35 | |
| 36 | ## Configuration |
| 37 | |
| 38 | This check doesn't have any configuration options. |
| 39 | |
| 40 | ## How to enable it |
| 41 | |
| 42 | This check is enabled by default for all configured Prometheus servers. |
| 43 | |
| 44 | Example: |
| 45 | |
| 46 | ```js |
| 47 | prometheus "prod" { |
| 48 | uri = "https://prometheus-prod.example.com" |
| 49 | timeout = "60s" |
| 50 | include = [ |
| 51 | "rules/prod/.*", |
| 52 | "rules/common/.*", |
| 53 | ] |
| 54 | } |
| 55 | |
| 56 | prometheus "dev" { |
| 57 | uri = "https://prometheus-dev.example.com" |
| 58 | timeout = "30s" |
| 59 | include = [ |
| 60 | "rules/dev/.*", |
| 61 | "rules/common/.*", |
| 62 | ] |
| 63 | } |
| 64 | ``` |
| 65 | |
| 66 | ## How to disable it |
| 67 | |
| 68 | You can disable this check globally by adding this config block: |
| 69 | |
| 70 | ```js |
| 71 | checks { |
| 72 | disabled = ["promql/range_query"] |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | You can also disable it for all rules inside given file by adding |
| 77 | a comment anywhere in that file. Example: |
| 78 | |
| 79 | `# pint file/disable promql/range_query` |
| 80 | |
| 81 | Or you can disable it per rule by adding a comment to it. Example: |
| 82 | |
| 83 | `# pint disable promql/range_query` |
| 84 | |
| 85 | If you want to disable only individual instances of this check |
| 86 | you can add a more specific comment. |
| 87 | |
| 88 | `# pint disable promql/range_query($prometheus)` |
| 89 | |
| 90 | Where `$prometheus` is the name of Prometheus server to disable. |
| 91 | |
| 92 | Example: |
| 93 | |
| 94 | `# pint disable promql/range_query(prod)` |
| 95 | |
| 96 | ## How to snooze it |
| 97 | |
| 98 | You can disable this check until given time by adding a comment to it. Example: |
| 99 | |
| 100 | `# pint snooze $TIMESTAMP promql/range_query` |
| 101 | |
| 102 | Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) |
| 103 | formatted or `YYYY-MM-DD`. |
| 104 | Adding this comment will disable `promql/range_query` *until* `$TIMESTAMP`, after that |
| 105 | check will be re-enabled. |
| 106 | |