Skip to content

Commit cd5cfdb

Browse files
[DOCS] Document regex circuit breaker (#76048) (#76127)
Documents the `script.painless.regex.enabled` and `script.painless.regex.limit-factor` cluster settings. Relates to #63029. Closes #75199. Co-authored-by: James Rodewig <[email protected]>
1 parent c9f0c52 commit cd5cfdb

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

docs/reference/ingest.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,10 @@ PUT _ingest/pipeline/my-pipeline
586586
}
587587
----
588588

589-
If the static `script.painless.regex.enabled` cluster setting is enabled, you
590-
can use regular expressions in your `if` condition scripts. For supported
591-
syntax, see the {painless}/painless-regexes.html[Painless regexes]
592-
documentation.
589+
If the <<script-painless-regex-enabled,`script.painless.regex.enabled`>> cluster
590+
setting is enabled, you can use regular expressions in your `if` condition
591+
scripts. For supported syntax, see {painless}/painless-regexes.html[Painless
592+
regular expressions].
593593

594594
TIP: If possible, avoid using regular expressions. Expensive regular expressions
595595
can slow indexing speeds.

docs/reference/modules/indices/circuit_breaker.asciidoc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,41 @@ documentation for more information.
129129
Limit for the number of unique dynamic scripts within a certain interval
130130
that are allowed to be compiled for a given context. Defaults to `75/5m`,
131131
meaning 75 every 5 minutes.
132+
133+
[[regex-circuit-breaker]]
134+
[discrete]
135+
==== Regex circuit breaker
136+
137+
Poorly written regular expressions can degrade cluster stability and
138+
performance. The regex circuit breaker limits the use and complexity of
139+
{painless}/painless-regexes.html[regex in Painless scripts].
140+
141+
[[script-painless-regex-enabled]]
142+
`script.painless.regex.enabled`::
143+
(<<static-cluster-setting,Static>>) Enables regex in Painless scripts. Accepts:
144+
145+
`limit` (Default):::
146+
Enables regex but limits complexity using the
147+
<<script-painless-regex-limit-factor,`script.painless.regex.limit-factor`>>
148+
cluster setting.
149+
150+
`true`:::
151+
Enables regex with no complexity limits. Disables the regex circuit breaker.
152+
153+
`false`:::
154+
Disables regex. Any Painless script containing a regular expression returns an
155+
error.
156+
157+
[[script-painless-regex-limit-factor]]
158+
`script.painless.regex.limit-factor`::
159+
(<<static-cluster-setting,Static>>) Limits the number of characters a regular
160+
expression in a Painless script can consider. {es} calculates this limit by
161+
multiplying the setting value by the script input's character length.
162+
+
163+
For example, the input `foobarbaz` has a character length of `9`. If
164+
`script.painless.regex.limit-factor` is `6`, a regular expression on `foobarbaz`
165+
can consider up to 54 (9 * 6) characters. If the expression exceeds this limit,
166+
it triggers the regex circuit breaker and returns an error.
167+
+
168+
{es} only applies this limit if
169+
<<script-painless-regex-enabled,`script.painless.regex.enabled`>> is `limit`.

0 commit comments

Comments
 (0)