Date
Synopsis
Parses dates from a field in various formats into a standardized timestamp.
Schema
date:
- field: <ident>
- formats: <enum[]>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- locale: <string>
- on_failure: <processor[]>
- on_success: <processor[]>
- output_format: <string>
- tag: <string>
- target_field: <ident>
- timezone: <string>
Configuration
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Field containing the date to parse |
formats | N | - | Array of expected date formats. Supports: standard Go time layouts, ISO8601 , UNIX , UNIX_MS |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if parsing fails |
locale | N | - | Locale for date parsing (e.g., "en_US") |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
output_format | N | 2006-01-02T15:04:05.000Z07:00 | Format pattern for the output timestamp |
tag | N | - | Identifier |
target_field | N | @timestamp | Field to store the parsed date |
timezone | N | UTC | Timezone for parsing (e.g., "Europe/Amsterdam") |
Details
The processor features an advanced timestamp parser that can automatically detect and parse a wide variety of date/time formats without requiring explicit format specification. It supports nearly all timestamp formats, including:
Years | YYYY , YY , yyyy , yy |
Months | MMMM (full name), MMM (abbreviated), MM (zero-padded), M |
Days | DD , D , dd , d |
Hours | HH (24-hour), hh (12-hour), h |
Minutes / Seconds | mm , m , ss , s |
Milliseconds | S , SSS , SSSSSS , SSSSSSSSS |
Timezones | Z , ZZ , ZZZ |
AM / PM | A , a |
Human-readable and machine timestamps, as well as Java time patterns and Go time layouts are supported. Numeric timestamps (i.e. Unix epoch in seconds/milliseconds) are handled.
Output formats and timezones are customizable. Also, templates can be used for dynamic timezone and locale selection.
By default, the parsed date is stored in the @timestamp
field, but this can be customized using target_field
.
Date parsing will fail if none of the specified formats match the input. Set ignore_failure
to true
if errors should be tolerated.
Examples
Standard Dates
Parsing a date using the standard format... |
|
converts it to the ISO format with timezone: |
|
Automatic Detection
Parsing various timestamps without explicit specs... |
|
detects and normalizes all dates automatically: |
|
Nested Fields with ISO8601
Processing dates in nested objects... |
|
maintains the correct timestamp: |
|
Output Formats
Specifying a custom format... |
|
generates the specified output: |
|
Dynamic Timezone and Locale
Template fields for timezone and locale... |
|
can be used for parsing: |
|