I would like to convert a string to a timestamp in grafana notification alert.
Example:
[
{
“status”: “firing”,
“annotations”: {
“summary”: “Instance instance1 has been down for more than 5 minutes”
},
“labels”: {
“timestamp”: “2025-02-19T03:15:48.219Z”,
},
“startsAt”: “2025-02-18T07:15:48.219Z”,
“endsAt”: “2025-02-19T07:20:48.219Z”,
“fingerprint”: “a5331f0d5a9d81d4”,
“generatorURL”: “http://grafana.com/alerting/grafana/cdeqmlhvflz40f/view”
},
]
According to documentation you can use “date” function to convert to a timestamp, but it does not work:
{{- if (index . “HourDK”) }}
- HourDK: {{ index . “HourDK” | date “2024-01-01” }}
{{- end }}
error:
template: :10:37: executing “test_markdown” at <“2024-01-01”>: wrong type for value; expected time.Time; got string