Skip to content

Commit cb22468

Browse files
[DOCS] Document regex circuit breaker (#76048) (#76130)
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 33d624e commit cb22468

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

docs/reference/ingest.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -772,10 +772,10 @@ PUT _ingest/pipeline/my-pipeline
772772
}
773773
----
774774

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

780780
TIP: If possible, avoid using regular expressions. Expensive regular expressions
781781
can slow indexing speeds.

docs/reference/modules/indices/circuit_breaker.asciidoc

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

0 commit comments

Comments
 (0)