Skip to content

Commit ad72e36

Browse files
Add section headers and cross-references per review suggestion
1 parent a1502b4 commit ad72e36

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/reference/enrich-processor/date-processor.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $$$date-options$$$
1515
| `field` | yes | - | The field to get the date from. |
1616
| `target_field` | no | @timestamp | The field that will hold the parsed date. |
1717
| `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). |
1919
| `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). |
2020
| `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). |
2121
| `description` | no | - | Description of the processor. Useful for describing the purpose of the processor or its configuration. |
@@ -24,14 +24,20 @@ $$$date-options$$$
2424
| `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). |
2525
| `tag` | no | - | Identifier for the processor. Useful for debugging and metrics. |
2626

27+
## Timezones [date-processor-timezones]
28+
2729
The `timezone` option may have two effects on the behavior of the processor:
2830
- 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`.
2931
- 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`.
3032

3133
::::{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.)
3335
::::
3436

37+
## Examples [date-processor-examples]
38+
39+
### Simple example [date-processor-simple-example]
40+
3541
Here is an example that adds the parsed date to the `timestamp` field based on the `initial_date` field:
3642

3743
```js
@@ -50,6 +56,8 @@ Here is an example that adds the parsed date to the `timestamp` field based on t
5056
}
5157
```
5258

59+
### Example using templated parameters [date-processor-templated-example]
60+
5361
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.
5462

5563
```js
@@ -69,6 +77,8 @@ The `timezone` and `locale` processor parameters are templated. This means that
6977
}
7078
```
7179

80+
### Example dealing with short timezone abbreviations safely [date-processor-short-timezone-example]
81+
7282
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.
7383

7484
```js
@@ -112,4 +122,4 @@ In the example below, the `message` field in the input is expected to be a strin
112122
}
113123
```
114124

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

Comments
 (0)