1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/otel-config-send-metrics-monitoring-stack.adoc

81 lines
2.9 KiB
Plaintext

// Module included in the following assemblies:
//
// * observability/otel/otel-configuring-metrics-for-monitoring-stack.adoc
:_mod-docs-content-type: REFERENCE
[id="configuration-for-sending-metrics-to-the-monitoring-stack_{context}"]
= Configuration for sending metrics to the monitoring stack
You can configure the `OpenTelemetryCollector` custom resource (CR) to create a Prometheus `ServiceMonitor` CR or a `PodMonitor` CR for a sidecar deployment. A `ServiceMonitor` can scrape Collector's internal metrics endpoint and Prometheus exporter metrics endpoints.
.Example of the OpenTelemetry Collector CR with the Prometheus exporter
[source,yaml]
----
apiVersion: opentelemetry.io/v1beta1
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:
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
pipelines:
metrics:
exporters: [prometheus]
----
<1> Configures the {OTELOperator} to create the Prometheus `ServiceMonitor` CR or `PodMonitor` CR to scrape the Collector's internal metrics endpoint and the Prometheus exporter metrics endpoints.
[NOTE]
====
Setting `enableMetrics` to `true` creates the following two `ServiceMonitor` instances:
* One `ServiceMonitor` instance for the `<instance_name>-collector-monitoring` service. This `ServiceMonitor` instance scrapes the Collector's internal metrics.
* One `ServiceMonitor` instance for the `<instance_name>-collector` service. This `ServiceMonitor` instance scrapes the metrics exposed by the Prometheus exporter instances.
====
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
[source,yaml]
----
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.