@@ -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