Search code examples
notificationsdatadogalerts

How to Format last_triggered_at Date in Datadog Notification Message


I'm working on setting up a notification message in Datadog and I'm trying to include the last_triggered_at timestamp in a specific format. I attempted to use the following syntax within the notification message template:

{{last_triggered_at|date("hh:mm:ss")}}

However, I encountered an error stating: "Error at character 49 of line 18 near {{last_triggered_at|date("hh:mm:ss")}}".

I'm looking for a way to format the last_triggered_at timestamp to display hours, minutes, and seconds (hh:mm:ss). Can anyone provide guidance on the correct syntax to achieve this formatting in Datadog's notification message template, or suggest an alternative approach?

Any help or insights would be greatly appreciated. Thank you in advance!


Solution

  • While the monitor messsages do support simple evaluation of template variables, formatting dates is not one of the functions provided. You need to add a grok parser as a processor for your logs, and do the formatting there. Then you can reference the pre-formatted variable in your notification message.