| layout | default |
|---|---|
| parent | Checks |
| grand_parent | Documentation |
This check will warn if metric selector uses a regexp match but the regexp query doesn't have any patterns and so a simple string equality match can be used. Since regexp checks are more expensive using a simple equality check if preferable.
Example of a query that would trigger this warning:
foo{job=~"bar"}job=~"bar" uses a regexp match but since it matches job value to a static string
there's no need to use a regexp here and job="bar" should be used instead.
Example of a query that wouldn't trigger this warning:
foo{job=~"bar|baz"}Another problem this check will report on is redundant regexp anchors.
As noted on Querying Prometheus
page Prometheus fully anchors all regex matchers.
So a query match using foo=~"bar.*" will be parsed as foo=~"^bar.*$" and
so any anchors used in the query will be redundant.
This means that passing foo=~"^bar.*$" to the query will be parsed as
foo=~"^^bar.*$$", so both ^ and $ should be skipped to avoid it.
This check doesn't have any configuration options.
This check is enabled by default.
You can disable this check globally by adding this config block:
checks {
disabled = ["promql/regexp"]
}You can also disable it for all rules inside given file by adding a comment anywhere in that file. Example:
# pint file/disable promql/regexpOr you can disable it per rule by adding a comment to it. Example:
# pint disable promql/regexpYou can disable this check until given time by adding a comment to it. Example:
# pint snooze $TIMESTAMP promql/regexpWhere $TIMESTAMP is either use RFC3339
formatted or YYYY-MM-DD.
Adding this comment will disable promql/regexp until $TIMESTAMP, after that
check will be re-enabled.