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

Possibility to define eventSeverity as an array rather than minimum version (ideally per source)

Open ilya-git opened this issue 4 years ago • 6 comments

I would like to get all error messages that are happening and some of the information messages e.g. for HelmChart or ImagePolicy. The reason is that these resources usually generate quite a lot of messages that are not very useful to get slack, but it's rather interesting to know if there is an error.

Since it is now only possible to chose either info or error (the former will send both errors and information), the only way I could do this is to have 2 different slack channels, one with selected information messages, the other with all resources error messages. It would be beneficial to join all messages in one slack channel, but it does not seem possible at the moment. Right now it will mean "double" error messages if set up with 2 alerts.

Additionally if we can provide eventServerity per event source (that will e.g. override alert event severity) it can help in keeping config smaller. Example possible configuration:

yaml

apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Alert
metadata:
  name: slack
  namespace: flux-system
spec:
  providerRef:
    name: slack
  eventSeverity: [info] # This will only send info and not error
  eventSources:
    - kind: GitRepository
      name: "*"
    - kind: ImagePolicy
      eventSeverity: [error]  # This override will allow to use the same alert and not a separate one, but is not as useful as choosing severities. Alternatively this can be added without changing top-level eventSeverity to override with an array per kind
      name: "*"

P.S. Perhaps exclusionList can also be overridden/merged per event source, but this is probably not directly connected to this feature request, just a note :)

ilya-git avatar Oct 20 '21 12:10 ilya-git

You can create 2 alerts that use the same provider, one for infos and one for errors only.

stefanprodan avatar Oct 20 '21 12:10 stefanprodan

Yes, I just figured out that I was not clear enough, @stefanprodan : I can do that, but the problem is that if I use the same slack channel, I'll get double errors, I will update the description. Or maybe there is a way to not get it and I just did not figure it out? Perhaps I can use different kind of resources in each of the alerts and this will do the trick

ilya-git avatar Oct 20 '21 12:10 ilya-git

Split by kind, here:

apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Alert
metadata:
  name: slack-infos-and-errors
  namespace: flux-system
spec:
  providerRef:
    name: slack
  eventSeverity: info
  eventSources:
    - kind: GitRepository
      name: "*"
    - kind: Kustomization
      name: "*"
---
apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Alert
metadata:
  name: slack-errors-only
  namespace: flux-system
spec:
  providerRef:
    name: slack
  eventSeverity: error 
  eventSources:
    - kind: HelmChart
      name: "*"
    - kind: ImagePolicy
      name: "*"

stefanprodan avatar Oct 20 '21 12:10 stefanprodan

Yes, thank you, that will do the trick I suppose :) I still think eventSeverity per event source can be a nice thing to have, but if you mean it's not necessary we can just close this issue as I have this option that you provided.

ilya-git avatar Oct 20 '21 12:10 ilya-git

Changing the eventSeverity type from string to an array is a breaking change. I would not do this unless there is no way to achieve something with the current API.

stefanprodan avatar Oct 20 '21 12:10 stefanprodan

What about adding an override to each event source? That won't be breaking if default will be the same as now

ilya-git avatar Oct 20 '21 12:10 ilya-git