One of two following custom resources (CR) configures the sending of metrics to the monitoring stack:
A configured OpenTelemetry Collector CR can create a Prometheus serviceMonitor
CR for scraping the Collector’s pipeline metrics and the enabled Prometheus exporters.
Example of the OpenTelemetry Collector CR with the Prometheus exporter
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
spec:
mode: deployment
observability:
metrics:
enableMetrics: true (1)
config: |
exporters:
prometheus:
endpoint: 0.0.0.0:8889
resource_to_telemetry_conversion:
enabled: true # by default resource attributes are dropped
service:
telemetry:
metrics:
address: ":8888"
pipelines:
metrics:
receivers: [otlp]
exporters: [prometheus]
1 |
Configures the Operator to create the Prometheus serviceMonitor CR to scrape the Collector’s internal metrics endpoint and Prometheus exporter metric endpoints. The metrics will be stored in the OpenShift monitoring stack. |
Alternatively, a manually created Prometheus PodMonitor
CR can provide fine control, for example removing duplicated labels added during Prometheus scraping.
Example of the PodMonitor
CR that configures the monitoring stack to scrape the Collector metrics
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: otel-collector
spec:
selector:
matchLabels:
app.kubernetes.io/name: <cr_name>-collector (1)
podMetricsEndpoints:
- port: metrics (2)
- port: promexporter (3)
relabelings:
- action: labeldrop
regex: pod
- action: labeldrop
regex: container
- action: labeldrop
regex: endpoint
metricRelabelings:
- action: labeldrop
regex: instance
- action: labeldrop
regex: job
1 |
The name of the OpenTelemetry Collector CR. |
2 |
The name of the internal metrics port for the OpenTelemetry Collector. This port name is always metrics . |
3 |
The name of the Prometheus exporter port for the OpenTelemetry Collector. |