Time Shift
Synopsis
Shifts timestamps by specified amounts with timezone conversion.
Schema
- timeshift:
field: <ident>
amount: <string>
unit: <string>
target_field: <string>
format: <string>
timezone: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Source field containing timestamp to shift |
amount | Y | - | Shift amount as numeric string (positive or negative) |
unit | Y | - | Time unit (seconds, minutes, hours, days, weeks, months, years) |
target_field | N | Same as field | Target field to store shifted timestamp |
format | N | RFC3339 | Output datetime format |
timezone | N | - | Target timezone for output |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if shift fails |
ignore_missing | N | false | Skip processing if referenced field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
Shifts timestamps by specified amounts supporting various time units and timezone conversions. The processor handles multiple input formats and provides flexible output formatting options.
The processor accepts timestamps in various formats including RFC3339, Unix timestamps (integer or float), and common date/time string formats. When no format is specified, it attempts to parse using common formats automatically.
Time units support both singular and plural forms with common abbreviations: seconds (s, sec, secs), minutes (m, min, mins), hours (h, hr, hrs), days (d), weeks (w), months, and years (y). Fractional amounts are supported for precise time shifts.
For months and years, the processor handles variable lengths carefully. Months use approximate calculations (30.44 days per month) for fractional parts, while years use 365.25 days to account for leap years.
Month and year calculations are approximate for fractional values. For precise date arithmetic, use whole number amounts or convert to days/hours for exact calculations.
Examples
Basic Time Shift
Shifting timestamp forward by 2 hours... |
|
adds 2 hours to timestamp: |
|
Timezone Conversion with Shift
Shifting time and converting timezone... |
|
shifts to previous day in EST: |
|
Unix Timestamp Processing
Processing Unix timestamp with custom format... |
|
formats shifted time as readable string: |
|
Negative Time Shift
Shifting timestamp backward for log correlation... |
|
creates earlier timestamp for correlation: |
|
Fractional Time Units
Using fractional hours for precise shifts... |
|
shifts by 1.5 hours with time-only format: |
|
Monthly Scheduling
Calculating monthly report dates... |
|
calculates quarterly report date: |
|
Week-based Scheduling
Calculating weekly maintenance windows... |
|
schedules next maintenance in local time: |
|
String Date Processing
Processing various string date formats... |
|
parses and shifts with readable output: |
|