You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/enrich-processor/date-processor.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ $$$date-options$$$
15
15
|`field`| yes | - | The field to get the date from. |
16
16
|`target_field`| no |@timestamp| The field that will hold the parsed date. |
17
17
|`formats`| yes | - | An array of the expected date formats. Can be a [java time pattern](/reference/elasticsearch/mapping-reference/mapping-date-format.md) or one of the following formats: ISO8601, UNIX, UNIX_MS, or TAI64N. |
18
-
|`timezone`| no | UTC | The default timezone used by the processor (see below). Supports [template snippets](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#template-snippets). |
18
+
|`timezone`| no | UTC | The default timezone used by the processor (see [below](#date-processor-timezones)). Supports [template snippets](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#template-snippets). |
19
19
|`locale`| no | ENGLISH | The locale to use when parsing the date, relevant when parsing month names or week days. Supports [template snippets](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#template-snippets). |
20
20
|`output_format`| no |`yyyy-MM-dd'T'HH:mm:ss.SSSXXX`| The format to use when writing the date to `target_field`. Must be a valid [java time pattern](/reference/elasticsearch/mapping-reference/mapping-date-format.md). |
21
21
|`description`| no | - | Description of the processor. Useful for describing the purpose of the processor or its configuration. |
@@ -24,14 +24,20 @@ $$$date-options$$$
24
24
|`on_failure`| no | - | Handle failures for the processor. See [Handling pipeline failures](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#handling-pipeline-failures). |
25
25
|`tag`| no | - | Identifier for the processor. Useful for debugging and metrics. |
26
26
27
+
## Timezones [date-processor-timezones]
28
+
27
29
The `timezone` option may have two effects on the behavior of the processor:
28
30
- If the string being parsed matches a format representing a local date-time, such as `yyyy-MM-dd HH:mm:ss`, it will be assumed to be in the timezone specified by this option. This is not applicable if the string matches a format representing a zoned date-time, such as `yyyy-MM-dd HH:mm:ss zzz`: in that case, the timezone parsed from the string will be used. It is also not applicable if the string matches an absolute time format, such as `epoch_millis`.
29
31
- The date-time will be converted into the timezone given by this option before it is formatted and written into the target field. This is not applicable if the `output_format` is an absolute time format such as `epoch_millis`.
30
32
31
33
::::{warning}
32
-
We recommend avoiding the use of short abbreviations for timezone names, since they can be ambiguous. For example, one JDK might interpret `PST` as `America/Tijuana`, i.e. Pacific (Standard) Time, while another JDK might interpret it as `Asia/Manila`, i.e. Philippine Standard Time. If your input data contains such abbreviations, you should convert them into either standard full names or UTC offsets using your own knowledge of what each abbreviation means in your data before parsing them. See below for an example. (This does not apply to `UTC`, which is safe.)
34
+
We recommend avoiding the use of short abbreviations for timezone names, since they can be ambiguous. For example, one JDK might interpret `PST` as `America/Tijuana`, i.e. Pacific (Standard) Time, while another JDK might interpret it as `Asia/Manila`, i.e. Philippine Standard Time. If your input data contains such abbreviations, you should convert them into either standard full names or UTC offsets using your own knowledge of what each abbreviation means in your data before parsing them. See [below](#date-processor-short-timezone-example) for an example. (This does not apply to `UTC`, which is safe.)
33
35
::::
34
36
37
+
## Examples [date-processor-examples]
38
+
39
+
### Simple example [date-processor-simple-example]
40
+
35
41
Here is an example that adds the parsed date to the `timestamp` field based on the `initial_date` field:
36
42
37
43
```js
@@ -50,6 +56,8 @@ Here is an example that adds the parsed date to the `timestamp` field based on t
50
56
}
51
57
```
52
58
59
+
### Example using templated parameters [date-processor-templated-example]
60
+
53
61
The `timezone` and `locale` processor parameters are templated. This means that their values can be extracted from fields within documents. The example below shows how to extract the locale/timezone details from existing fields, `my_timezone` and `my_locale`, in the ingested document that contain the timezone and locale values.
54
62
55
63
```js
@@ -69,6 +77,8 @@ The `timezone` and `locale` processor parameters are templated. This means that
69
77
}
70
78
```
71
79
80
+
### Example dealing with short timezone abbreviations safely [date-processor-short-timezone-example]
81
+
72
82
In the example below, the `message` field in the input is expected to be a string formed of a local date-time in `yyyyMMddHHmmss` format, a timezone abbreviated to one of `PST`, `CET`, or `JST` representing Pacific, Central European, or Japan time, and a payload. This field is split up using a `grok` processor, then the timezones are converted into full names using a `script` processor, then the date-time is parsed using a `date` processor, and finally the unwanted fields are discarded using a `drop` processor.
73
83
74
84
```js
@@ -112,4 +122,4 @@ In the example below, the `message` field in the input is expected to be a strin
112
122
}
113
123
```
114
124
115
-
With that pipeline, a `message` field with the value `20250102123456 PST Hello world` will result in a `@timestamp` field with the value `2025-01-02T12:34:56.000-08:00` and a `payload` field with the value `Hello world`. (Note: A `@timestamp` field will normally be mapped to a `date` type, and therefore it will be indexed as an integer representing milliseconds since the epoch, although the original format and timezone may be preserved in the `_source`.)
125
+
With this pipeline, a `message` field with the value `20250102123456 PST Hello world` will result in a `@timestamp` field with the value `2025-01-02T12:34:56.000-08:00` and a `payload` field with the value `Hello world`. (Note: A `@timestamp` field will normally be mapped to a `date` type, and therefore it will be indexed as an integer representing milliseconds since the epoch, although the original format and timezone may be preserved in the `_source`.)
0 commit comments