Format Timestamp action
Available for event, alert, and incident workflows |
This action formats an epoch timestamp as a human-readable date and time. An epoch timestamp logs the number of seconds elapsed since January 1st, 1970. For information on converting dates and times to epoch format, see this external resource.
This action takes the following inputs:
Input Field
The epoch timestamp object field to format.
Date/Time Format
The new format for the timestamp, as defined by a string pattern. The default pattern is:
yyyy/MM/dd h:mm:ss a
For example, using the default pattern, an epoch timestamp of
1678220899
will be converted to the following format:2023/03/07 8:28:19 PM
To define a new pattern, see the following section on Defining patterns for formatting.
Timezone
The timezone for the formatted timestamp.
Output Field
The field where you would like to place the formatted timestamp. Reusing the input field here is allowed.
Defining patterns for formatting
Patterns for defining a date/time format are based on simple sequences of letters and symbols. All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The following pattern letters are defined:
Symbol | Date or time meaning | Examples of output |
---|---|---|
G | Era |
|
u | Year |
|
y | Year of era |
|
D | Day of year |
|
M | Month of year |
|
d | Day of month |
|
g | Modified Julian day |
|
Q | Quarter of year |
|
Y | Week-based year |
|
w | Week of week-based year |
|
W | Week of month |
|
E | Day of week |
|
e | Localized day of week |
|
F | Day of week in month |
|
a | AM/PM of day |
|
h | Clock hour of AM/PM (1-12) |
|
K | Hour of AM/PM (0-11) |
|
k | Clock hour of day (1-24) |
|
H | Hour of day (0-23) |
|
m | Minute of hour |
|
s | Second of minute |
|
S | Fraction of second |
|
A | Millisecond of day |
|
n | Nanosecond of second |
|
N | Nanosecond of day |
|
v | Generic time-zone name |
|
z | Time zone name |
|
O | Localized zone offset |
|
X | Zone offset (prints 'Z' for the zone offset 'Zero') |
|
x | Zone offset (prints '+00' for the zone offset 'Zero') |
|
Z | Zone offset |
|
p | Pad next (pads the output of the pattern after it with spaces) | |
' | Escape for text |
|
'' | Single quote | ' |
[ | Optional section start | |
] | Optional section end |
Note that the format of the output is decided by the number of letters used in the pattern.
Example: MMMM
formats the month in year as December
, while MMM
outputs the month in year as Dec
.
Additionally, all non-letter characters other than '[', ']', '{', '}', '#' and the single quotation mark display in the output literally.
Event example
Format Timestamp works the same way for both events and incidents.
In this example, suppose that new events are generated with an epoch timestamp stored in a tag called tags.time
. You want to adjust this timestamp for all new events to display the time in this format instead:
01 January 2023
You can accomplish this by creating an event workflow with a Format Timestamp action. After setting up the trigger, you can configure the Format Timestamp action as follows:
Input Field:
tags.time
Date/Time Format:
dd MMMM yyyy
Timezone: (GMT-08:00) Pacific Time (US and Canada) - America/Los_Angeles
Output Field:
tags.time
Here is an example event that was processed by this workflow:
Event fields before | Event fields after |
---|---|
{ "description": "CPU spike to 70%", "severity": 4, "source": "ussf-sw99", "check": "cpu", "service": [ "retail", "support" ], "tags": { "serverID": "1022", "time": 1672611819 } } | { "description": "CPU spike to 70%", "severity": 4, "source": "ussf-sw99", "check": "cpu", "service": [ "retail", "support" ], "timestamp": 1672611819, "tags": { "serverID": "1022", "time": "01 January 2023" } } |
Alert example
In this example, new events are generated with an epoch timestamp stored in a tag called tags.time
. You want to adjust this timestamp for all new events to display the time in this format instead:
01/01/2022 00:00:00
Input Field:
tags.time
Date/Time Format:
MM/dd/yyyy HH:mm:ss
Timezone: (GMT+00:00) UTC - UTC
Output Field:
tags.time
Here's an example alert that was processed by this workflow:
Alert fields before | Alert fields after |
---|---|
{ ... "tags": { "integration_type": [ "eventapi" ], "time": 1682977511 } ... } | { ... "tags": { "integration_type": [ "eventapi" ], "time": "05/01/2023 21:45:11" } ... } |
Incident example
In this example, suppose that for all new incidents, you want to convert the epoch timestamp value in the created_at
field into the following format and store it in a tag called tags.creation_time
:
01-Jan-2022 00:00:00
You can accomplish this by creating an incident workflow with a Format Timestamp action. After setting up the trigger, configure the Format Timestamp action as follows:
Input Field:
created_at
Date/Time Format:
dd-M-yyyy hh:mm:ss
Timezone: (GMT+00:00) UTC - UTC
Output Field:
tags.creation_time
Here is an example incident that was processed by this workflow:
Incident fields before | Incident fields after |
---|---|
{ "status": "open", "severity": "major", "description": "CPU above 70%", "classes": [ "Compute" ], "services": [ "support", "retail" ], "tags": { }, "severity_high_water": "major", "first_event_time": 1682977509, "last_event_time": 1682977509, "incident_id": 3, "created_at": 1682977511, "last_state_change": 1682977511, "correlation_definition": "65232808-474f-4118-8234-c401865442e6", "alerts": [ 3 ], "in_maintenance": false, "total_alerts": 1, "manual_description_set": true, "resolving_steps": 0, "status_numeric": 1, "severity_numeric": 4 } | { "status": "open", "severity": "major", "description": "CPU above 70%", "classes": [ "Compute" ], "services": [ "support", "retail" ], "tags": { "creation_time": [ "01-May-2023 21:45:11" ] }, "severity_high_water": "major", "first_event_time": 1682977509, "last_event_time": 1682977509, "incident_id": 3, "created_at": 1682977511, "last_state_change": 1682977511, "correlation_definition": "65232808-474f-4118-8234-c401865442e6", "alerts": [ 3 ], "in_maintenance": false, "total_alerts": 1, "manual_description_set": true, "resolving_steps": 0, "status_numeric": 1, "severity_numeric": 4 } |