第7章 モニタリングスタックのメトリクスの設定
クラスター管理者は、OpenTelemetry Collector カスタムリソース (CR) を設定して、次のタスクを実行できます。
-
Collector のパイプラインメトリクスと有効な Prometheus エクスポーターをスクレイプするための Prometheus
ServiceMonitorCR を作成します。 - クラスター内モニタリングスタックからメトリクスを取得するように Prometheus Receiver を設定します。
7.1. モニタリングスタックにメトリクスを送信するための設定 リンクのコピーリンクがクリップボードにコピーされました!
OpenTelemetryCollector カスタムリソース (CR) を設定して、サイドカーデプロイメント用の Prometheus ServiceMonitor CR または PodMonitor CR を作成できます。ServiceMonitor は、Collector の内部メトリクスエンドポイントと Prometheus エクスポーターメトリクスエンドポイントをスクレイピングできます。
Prometheus エクスポーターを使用した OpenTelemetry Collector CR の例
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
spec:
mode: deployment
observability:
metrics:
enableMetrics: true
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
- Red Hat build of OpenTelemetry Operator を設定して Prometheus
ServiceMonitorCR またはPodMonitorCR を作成し、Collector の内部メトリクスエンドポイントと Prometheus エクスポーターメトリクスエンドポイントをスクレイピングします。
enableMetrics を true に設定すると、次の 2 つの ServiceMonitor インスタンスが作成されます。
-
<instance_name>-collector-monitoringサービス用の 1 つのServiceMonitorインスタンス。このServiceMonitorインスタンスは、Collector の内部メトリクスをスクレイピングします。 -
<instance_name>-collectorサービス用の 1 つのServiceMonitorインスタンス。このServiceMonitorインスタンスは、Prometheus エクスポーターインスタンスによって公開されるメトリクスをスクレイピングします。
あるいは、手動で作成した Prometheus PodMonitor CR を使用すると、Prometheus のスクレイピング中に追加された重複ラベルの削除など、細かい制御を行うことができます。
Collector メトリクスをスクレイプするようにモニタリングスタックを設定する PodMonitor CR の例
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: otel-collector
spec:
selector:
matchLabels:
app.kubernetes.io/name: <cr_name>-collector
podMetricsEndpoints:
- port: metrics
- port: promexporter
relabelings:
- action: labeldrop
regex: pod
- action: labeldrop
regex: container
- action: labeldrop
regex: endpoint
metricRelabelings:
- action: labeldrop
regex: instance
- action: labeldrop
regex: job