Is formating time in InfluxDB/Kapacitor possible?

I’ve used following workaround to get the timestamp in unix time:
using eval and lambda to create new field called timestamp and then you can reference to it as to any other field in the alert.message():

|eval(lambda: int(unixNano("time")/1000000000))
    .as('timestamp')

|alert()
    .message("Current timestamp is {{ index .Fields "timestamp" }}")

Hope this saves some time to others.

2 Likes