我已经为开放遥测收集器、prometheus和jaeger配置了docker compose,并通过otel代理发送数据。Jaeger工作正常,但prometheus没有显示任何指标,尽管收集器接收指标数据。
以下是我的配置:
docker-compose.yml:
# docker-compose.yml file
version: "3.5"
services:
jaeger:
container_name: jaeger
hostname: jaeger
networks:
- backend
image: jaegertracing/all-in-one:latest
volumes:
- "./jaeger-ui.json:/etc/jaeger/jaeger-ui.json"
command: --query.ui-config /etc/jaeger/jaeger-ui.json
environment:
- METRICS_STORAGE_TYPE=prometheus
- PROMETHEUS_SERVER_URL=http://prometheus:9090
ports:
- "14250:14250"
- "14268:14268"
- "6831:6831/udp"
- "16686:16686"
- "16685:16685"
collector:
container_name: collector
hostname: collector
networks:
- backend
image: otel/opentelemetry-collector-contrib:latest
volumes:
- "./otel-collector-config.yml:/etc/otelcol/otel-collector-config.yml"
command: --config /etc/otelcol/otel-collector-config.yml
ports:
- "5555:5555"
- "6666:6666"
depends_on:
- jaeger
prometheus:
container_name: prometheus
hostname: prometheus
networks:
- backend
image: prom/prometheus:latest
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
networks:
backend:
otel-collector-config.yml:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:5555
processors:
batch:
timeout: 1s
send_batch_size: 1
exporters:
prometheus:
endpoint: "collector:6666"
jaeger:
endpoint: "jaeger:14250" # using the docker-compose name of the jaeger container
tls:
insecure: true
service:
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ jaeger ]
metrics:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ prometheus ]
prometheus.yml:
global:
scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 1s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
scrape_configs:
- job_name: collector
scrape_interval: 1s
static_configs:
- targets: [ 'collector:6666' ] # using the name of the OpenTelemetryCollector container defined in the docker compose file
下面是我的tracer.properties配置用于otel代理的java:
otel.traces.exporter=otlp,logging
otel.metrics.exporter=otlp
otel.logs.exporter=none
otel.service.name=service1
otel.exporter.otlp.endpoint=http://0.0.0.0:5555
otel.exporter.otlp.protocol=grpc
otel.traces.sampler=always_on
otel.metric.export.interval=1000
我可以毫无问题地在jaeger中获取跟踪数据:
但是,指标不起作用:
我也无法在Prometheus中看到任何指标数据:
我缺少什么配置才能让它工作?还请指定如何为生产优化它。
1条答案
按热度按时间zazmityj1#
Prometheus导出器的绑定地址是
"collector:6666"
,这意味着创建的服务器将只接受端口6666
上的请求,并且只接受来自主机collector
的请求,但是Prometheus的主机不同,最好绑定到“任何地址”,例如"0.0.0.0:6666"
。此外,您可以使用
prometheusremotewrite
导出器而不是prometheus
,这样您就可以在收集器日志中看到问题。