File: inc_timestring_regex.asciidoc

package info (click to toggle)
elasticsearch-curator 8.0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,716 kB
  • sloc: python: 17,838; makefile: 159; sh: 156
file content (34 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[WARNING]
.A word about regular expression matching with timestrings
==========================================================
Timestrings are parsed from strftime patterns, like `%Y.%m.%d`, into regular
expressions.  For example, `%Y` is 4 digits, so the regular expression for that
looks like `\d{4}`, and `%m` is 2 digits, so the regular expression is `\d{2}`.

What this means is that a simple timestring to match year and month, `%Y.%m`
will result in a regular expression like this: `^.*\d{4}\.\d{2}.*$`.  This
pattern will match any 4 digits, followed by a period `.`, followed by 2 digits,
occurring anywhere in the index name.  This means it _will_ match monthly
indices, like `index-2016.12`, as well as daily indices, like
`index-2017.04.01`, which may not be the intended behavior.

To compensate for this, when selecting indices matching a subset of another
pattern, use a second filter with `exclude` set to `True`

[source,yaml]
-------------
- filtertype: pattern
 kind: timestring
 value: '%Y.%m'
- filtertype: pattern
 kind: timestring
 value: '%Y.%m.%d'
 exclude: True
-------------

This will prevent the `%Y.%m` pattern from matching the `%Y.%m` part of the
daily indices.

*This applies whether using `timestring` as a mere pattern match, or as part of
date calculations.*
==========================================================