getsentry / sentry-kubernetes

Kubernetes event reporter for Sentry
Apache License 2.0
458 stars 64 forks source link

Limit error forwarding to specific Namespaces #17

Closed geota closed 4 years ago

geota commented 5 years ago

Is there a way to limit the forwarding of errors to particular namespace(s)?

i.e. I have a sandbox namespace that I do not care to send errors into sentry for. Can I filter this namespace out?

bretthoerner commented 5 years ago

We allow you to select a single namespace to monitor with this env var:

https://github.com/getsentry/sentry-kubernetes/blob/a254c4b7c04262a07fc0ea9b089e02dd65824e15/sentry-kubernetes.py#L30

I'm open to PRs if you want to add logic to filter namespaces out.

geota commented 5 years ago

Thanks, before I start on the PR -

how would you like this implemented?

Simplest implementation would be just a whitelist or blacklist:

whitelist approach:

values.watchNamespaces:
- namespace1ToInclude
- namespace2ToInclude

blacklist approach:

values.filterNamespaces:
- namespace1ToFilter
- namespace2ToFilter

I could also just provide a regex field that users can set to that would match all the namespaces they want to monitor.

values.watchNamespaces: 'somecrazy-regex-*'

I am leaning towards the whitelist approach since its very explicit and errors in newly created namespaces would NOT automatically get sent to sentry, which I think follows the principle of least astonishment.

Of course, not setting this field would default to the existing behavior.

I would merge the the ENV var defined namespace into the whitelist defined namespace.

Not sure what the expected behavior would be for if someone defines the ENV var and then provides the same namespace in the blacklist.

thoughts?

bretthoerner commented 5 years ago

I agree whitelist would be best. I think something as simple as allowing EVENT_NAMESPACE to be a comma separated list is fine, too.

maestrofjp commented 4 years ago

I think this issue is OBE (overcome by events) as EVENT_NAMESPACE allows a comma list in a string of namespaces to watch.