notification-controller icon indicating copy to clipboard operation
notification-controller copied to clipboard

Feature Request: Allow Relabeling of Alerts

Open siegenthalerroger opened this issue 3 years ago • 7 comments

In our alerting stack we use Prometheus AlertManager and use a defined list of labels to correctly route any Alerts that are pushed to AM. The alerts sent by the notification controller to AM however use a different list of labels (or even more precisely different values than we expect). It would be beneficial to have way to relabel the alerts before they are sent to other systems.

I see two ways of our issue being properly solved. The easy version would be to allow renaming of labels before they are sent (e.g. namespace -> vendor). This does not address the issue of changing alert values which is considerably harder and I would consider that out of scope.

siegenthalerroger avatar Dec 09 '21 15:12 siegenthalerroger

We have the same problem. We need to route the notification to the right team based on a specific label. Maybe it could be possible to allow adding custom label in the Alert?

antoineozenne avatar Feb 03 '22 15:02 antoineozenne

I knocked up a proof of concept around this and it's relatively trivial to implement.

The sticking point is how to get the configuration into the provider. At the moment providers don't allow you to have a bespoke configuration passed in for that provider.

Alan01252 avatar Aug 26 '22 13:08 Alan01252

@stefanprodan do you have any thoughts on the above? The crux of the problem is we need some way to pass bespoke configuration to a provider.

My thoughts are that the provider could optionally take a ConfigurationRef containing ( optional ) bespoke configuration that could be read by the provider when instantiated.

I'd like to work on implementing this if you feel there's merit to the approach.

Alan01252 avatar Sep 07 '22 12:09 Alan01252

We copy the event metadata to the alertmanager labels, based on this we could inject the Alert.metadata.labels into the event before it gets sent to the provider. While this will allow setting custom labels it will not allow relabelling such as namespace -> vendor.

stefanprodan avatar Sep 08 '22 08:09 stefanprodan

Would that mean the flux project isn't open to ConfigurationRef style solution ( and that's a perfectly acceptable response ) to satisfy the relabelling feature?

My ( and I never would expect this pull request to be merged/consider to be merged ) brute force proof of concept implementation is here for those interested https://github.com/fluxcd/notification-controller/compare/main...Alan01252:notification-controller:feature/alert-relabelling

Alan01252 avatar Sep 08 '22 09:09 Alan01252

@stefanprodan adding custom labels would already be useful, however relabelling would definitely be useful as well.

siegenthalerroger avatar Sep 08 '22 11:09 siegenthalerroger

We copy the event metadata to the alertmanager labels, based on this we could inject the Alert.metadata.labels into the event before it gets sent to the provider. While this will allow setting custom labels it will not allow relabelling such as namespace -> vendor.

Something as simple as https://github.com/Alan01252/notification-controller/commit/b23dc546bfd5345f2d3736cf7c7e1fa482cfc7d9 would work I guess. Need to be cautious about labels potentially being overridden by the alert labels.

Alan01252 avatar Sep 08 '22 11:09 Alan01252