我使用以下内容部署了 Opentelemetry 收集器:
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: otel-metrics
namespace: otel-metrics
spec:
mode: statefulset
targetAllocator:
enabled: true
serviceAccount: opentelemetry-targetallocator-sa
prometheusCR:
enabled: true
config: |
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'otel-metrics'
scrape_interval: 30s
static_configs:
- targets: [ '0.0.0.0:8888' ]
exporters:
logging:
verbosity: detailed
prometheus:
endpoint: "0.0.0.0:8889"
send_timestamps: true
metric_expiration: 180m
service:
pipelines:
metrics:
receivers:
- prometheus
processors: []
exporters:
- logging
- prometheus
telemetry:
logs:
level: "debug"
但是,当我查看收集器的配置映射时,我可以看到它创建的 URL 仅在寻找
otel-metrics
的作业:
receivers:
prometheus:
config:
scrape_configs:
- http_sd_configs:
- url: http://otel-metrics-targetallocator:80/jobs/otel-metrics/targets?collector_id=$POD_NAME
如果我卷曲端点
http://otel-metrics-targetallocator:80/jobs
,我可以看到还有很多其他作业(例如以下),但这些显然不会被收集器拾取,因为 URL 的范围仅限于 otel-metrics
作业.
"serviceMonitor/monitoring/kube-state-metrics/0": {
"_link": "/jobs/serviceMonitor%2Fmonitoring%2Fkube-state-metrics%2F0/targets"
},
如何让目标分配器将所有 serviceMonitor 置于一项作业下,以便可由一个收集器拾取它们?