fluxcd / notification-controller

The GitOps Toolkit event forwarder and notification dispatcher
https://fluxcd.io
Apache License 2.0
150 stars 131 forks source link

Alertmanager: Change timestamp label to .StartsAt #795

Closed tdemin closed 4 months ago

tdemin commented 5 months ago

notification-controller posted all outgoing Alertmanager alerts with "timestamp" label, effectively preventing grouping alerts related to the same resource and forcing users to configure a separate alert receiver with send_resolved: false.

This changes it to instead set "startsAt", which was previously set (automatically by Alertmanager) to alert posting time. "endsAt" remains unset, as we have no way of figuring that out but the reconciliation interval of the resource that generated the alert, which can currently only be found out by making a Kubernetes API round-trip.

Note that this requires users to adapt alert templates that relied on .Labels.Timestamp.

Fixes #793.

tdemin commented 4 months ago

@stefanprodan sorry for taking a while to update this. I've expanded the docs on this.

While we're at it, I also updated fmt.Stringer / json.Marshaler implementations of AlertManagerTime to use value receiver types instead of pointers, as this is what Go stdlib docs tell us to do:

Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type time.Time, not *time.Time.