open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
3.09k stars 2.38k forks source link

[receiver/k8sobjects] allow options to exclude namespace #36217

Open KyriosGN0 opened 1 week ago

KyriosGN0 commented 1 week ago

Component(s)

receiver/k8sobjects

Is your feature request related to a problem? Please describe.

yes, in our cluster we have seen that in certain namespace that is has a heavy spike pattern and generates around 50k events, this causes our otel daemonset to get killed my oom

Describe the solution you'd like

we would like the optiont to exclude namespace when using the k8sobjects receiver

Describe alternatives you've considered

No response

Additional context

No response

github-actions[bot] commented 1 week ago

Pinging code owners:

atoulme commented 1 week ago

You can already set namespaces to scrape here: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/k8sobjectsreceiver/README.md?plain=1#L54

Do you want to enhance that option?

KyriosGN0 commented 1 week ago

@atoulme as far as i understand its a whitelist, i want the option to blacklist namespace

atoulme commented 1 week ago

OK, please explain how those 2 options would coexist. Please offer a configuration example.

KyriosGN0 commented 1 week ago

@atoulme namespaceWhitelist: [<Regex of namespace in include>] namespaceBlacklist: [<Regex of namespace to exclude>] or we could use labels to select which namespaces are exclude/included as for coexist, we would need to build a list of namespace to watch based on those regex/labels and then pass it to if statement here

i do think its more useful to exclude namespace since in my experience i want to stop watching namespaces with high amount of events

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/2612314ed7652a1379381e5b9068352a4af18fa5/receiver/k8sobjectsreceiver/receiver.go#L113

atoulme commented 1 week ago

whitelist and blacklist are no longer in use ; typically we use allowlist and denylist. We also try really hard to keep configuration backwards compatible ; there is already a namespaces option taking a list of namespaces. What is the smallest change that will get you what you need?

KyriosGN0 commented 1 week ago

@atoulme a list of namespace to exclude