3.3. 監視スタックにメトリクスを送信するための設定
OpenTelemetry Collector カスタムリソース (CR) は、Collector のパイプラインメトリクスと有効な Prometheus エクスポーターをスクレイプするための Prometheus ServiceMonitor CR を作成するように設定できます。
Prometheus エクスポーターを使用した OpenTelemetry Collector カスタムリソースの例
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:
address: ":8888"
pipelines:
metrics:
receivers: [otlp]
exporters: [prometheus]
- 1
- コレクターの内部メトリクスエンドポイントと Prometheus エクスポーターメトリクスエンドポイントをスクレイプする Prometheus
ServiceMonitorCR を作成するように Operator を設定します。メトリクスは OpenShift モニタリングスタックに保存されます。
あるいは、手動で作成した Prometheus PodMonitor を使用すると、Prometheus のスクレイピング中に追加された重複したラベルを削除するなど、細かい制御を行うことができます。
Collector メトリクスをスクレイプするように監視スタックを設定する PodMonitor カスタムリソースの例
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