第7章 モニタリングスタックのメトリクスの設定
クラスター管理者は、OpenTelemetry Collector カスタムリソース (CR) を設定して、次のタスクを実行できます。
-
Collector のパイプラインメトリクスと有効な Prometheus エクスポーターをスクレイプするための Prometheus
ServiceMonitorCR を作成します。 - クラスター内モニタリングスタックからメトリクスを取得するように Prometheus Receiver を設定します。
7.1. モニタリングスタックにメトリクスを送信するための設定 リンクのコピーリンクがクリップボードにコピーされました!
次の 2 つのカスタムリソース (CR) のいずれかによって、モニタリングスタックへのメトリクスの送信が設定されます。
- OpenTelemetry Collector CR
-
Prometheus
PodMonitorCR
設定された OpenTelemetry Collector CR は、Collector のパイプラインメトリクスと有効な Prometheus エクスポーターをスクレイプするための Prometheus ServiceMonitor CR を作成できます。
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
- Collector の内部メトリクスエンドポイントと Prometheus エクスポーターメトリクスエンドポイントをスクレイプする Prometheus
ServiceMonitorCR を作成するように Operator を設定します。メトリクスは OpenShift モニタリングスタックに保存されます。
あるいは、手動で作成した 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