open-telemetry / opentelemetry-operator

Kubernetes Operator for OpenTelemetry Collector
Apache License 2.0
1.2k stars 432 forks source link

Create a ServiceMonitor for the operator metrics endpoint #3370

Open iblancasa opened 4 days ago

iblancasa commented 4 days ago

Component(s)

No response

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

Currently, we are creating the ServiceMonitor for the OpenTelemetry Operator's metrics endpoint statically from a manifest file. However, this approach has a significant limitation: users may install the operator in a namespace other than the default namespace provided in the manifest. When users specify tlsConfig, this leads to a failure in scraping metrics, as the serverName field in the ServiceMonitor depends on the namespace where the operator was deployed.

Describe the solution you'd like

Enhance the operator to create the ServiceMonitor programmatically, ensuring it is configured automatically based on the namespace where the operator is installed. This will dynamically adjust the serverName and ensure metrics scraping works regardless of the installation namespace.

Describe alternatives you've considered

No response

Additional context

No response

pavolloffay commented 2 days ago

Cross-linking this with operator-sdk issue to handle SM by OLM https://github.com/operator-framework/operator-sdk/issues/6846