cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/checks/rule/link.md
142lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | parent: Checks |
| 4 | grand_parent: Documentation |
| 5 | --- |
| 6 | |
| 7 | # rule/link |
| 8 | |
| 9 | This check allows to validate if URLs passed in alerting rule |
| 10 | annotations. It will send a GET request to each link matching |
| 11 | configured regexp and warn if it gets a non-200 response. |
| 12 | |
| 13 | ## Configuration |
| 14 | |
| 15 | Syntax: |
| 16 | |
| 17 | ```js |
| 18 | link "$pattern" { |
| 19 | comment = "..." |
| 20 | severity = "bug|warning|info" |
| 21 | uri = "..." |
| 22 | timeout = "1m" |
| 23 | headers = { ... } |
| 24 | } |
| 25 | ``` |
| 26 | |
| 27 | - `$pattern` - regexp pattern to match, each rule will only check link |
| 28 | URLs that match this patter. This can be templated to reference checked |
| 29 | rule fields, see [Configuration](../../configuration.md) for details. |
| 30 | - `uri` - optional URI rewrite rule, this will be used as the URI for all |
| 31 | requests if specified, regexp capture groups can be referenced here. |
| 32 | - `comment` - set a custom comment that will be added to reported problems. |
| 33 | - `severity` - set custom severity for reported issues, defaults to a bug. |
| 34 | - `timeout` - timeout to be used for all request, defaults to 1 minute. |
| 35 | - `headers` - a list of HTTP headers to set on all requests. |
| 36 | |
| 37 | ## How to enable it |
| 38 | |
| 39 | This check is not enabled by default as it requires explicit configuration |
| 40 | to work. |
| 41 | To enable it add one or more `rule {...}` blocks and specify all rejected patterns |
| 42 | there. |
| 43 | |
| 44 | Examples: |
| 45 | |
| 46 | Validate all links found in alert annotations: |
| 47 | |
| 48 | ```js |
| 49 | rule { |
| 50 | link "https?://.+" {} |
| 51 | } |
| 52 | ``` |
| 53 | |
| 54 | Only validate HTTPS links, ignore plain HTTP. |
| 55 | |
| 56 | ```js |
| 57 | rule { |
| 58 | link "https://.+" {} |
| 59 | } |
| 60 | ``` |
| 61 | |
| 62 | Only validate specific hostname. |
| 63 | |
| 64 | ```js |
| 65 | rule { |
| 66 | link "https?://runbooks.example.com/.+" { |
| 67 | comment = "Please link every alert to a run-book" |
| 68 | } |
| 69 | } |
| 70 | ``` |
| 71 | |
| 72 | Rewrite URI to use `http://docs.internal.example.com/foo.html` instead of |
| 73 | `https://docs.example.com/foo.html`: |
| 74 | |
| 75 | ```js |
| 76 | rule { |
| 77 | link "https?://docs.example.com/(.+)" { |
| 78 | uri = "http://docs.internal.example.com/$1" |
| 79 | } |
| 80 | } |
| 81 | ``` |
| 82 | |
| 83 | Set `X-Auth` header for all requests. |
| 84 | |
| 85 | ```js |
| 86 | rule { |
| 87 | link "https?://runbooks.example.com/.+" { |
| 88 | headers = { |
| 89 | X-Auth = "secret key" |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | ``` |
| 94 | |
| 95 | ## How to disable it |
| 96 | |
| 97 | You can disable this check globally by adding this config block: |
| 98 | |
| 99 | ```js |
| 100 | checks { |
| 101 | disabled = ["rule/link"] |
| 102 | } |
| 103 | ``` |
| 104 | |
| 105 | You can also disable it for all rules inside given file by adding |
| 106 | a comment anywhere in that file. Example: |
| 107 | |
| 108 | ```yaml |
| 109 | # pint file/disable rule/link |
| 110 | ``` |
| 111 | |
| 112 | Or you can disable it per rule by adding a comment to it. Example: |
| 113 | |
| 114 | ```yaml |
| 115 | # pint disable rule/link |
| 116 | ``` |
| 117 | |
| 118 | If you want to disable only individual instances of this check |
| 119 | you can add a more specific comment. |
| 120 | |
| 121 | ```yaml |
| 122 | # pint disable rule/link($pattern) |
| 123 | ``` |
| 124 | |
| 125 | Example: |
| 126 | |
| 127 | ```yaml |
| 128 | # pint disable rule/link(^https?://.+$) |
| 129 | ``` |
| 130 | |
| 131 | ## How to snooze it |
| 132 | |
| 133 | You can disable this check until given time by adding a comment to it. Example: |
| 134 | |
| 135 | ```yaml |
| 136 | # pint snooze $TIMESTAMP rule/link |
| 137 | ``` |
| 138 | |
| 139 | Where `$TIMESTAMP` is either use [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) |
| 140 | formatted or `YYYY-MM-DD`. |
| 141 | Adding this comment will disable `rule/link` *until* `$TIMESTAMP`, after that |
| 142 | check will be re-enabled. |
| 143 | |