hashicorp/consul-telemetry-collectorConsul Telemetry Collector是基于OpenTelemetry规范构建的轻量级遥测数据收集器,专注于Consul服务网格的可观测性数据采集与处理。该镜像旨在简化Consul环境中的遥测数据收集流程,支持指标(Metrics)、日志(Logs)和分布式追踪(Traces)的标准化采集,并可灵活导出至各类可观测性平台。其轻量级设计使其适用于边缘环境、容器化部署及资源受限场景。
bashdocker run -d \ --name consul-telemetry-collector \ -v $(pwd)/otel-config.yaml:/etc/otel/config.yaml \ -e CONSUL_ADDR=[***] \ -e OTEL_EXPORTER_OTLP_ENDPOINT=[***] \ -p 8889:8889 \ hashicorp/consul-telemetry-collector:latest
参数说明:
-v:挂载本地配置文件到容器内默认配置路径-e:设置环境变量(Consul地址、导出端点等)-p:暴露Prometheus指标端口(如需本地采集)yamlversion: '3.8' services: consul-agent: image: hashicorp/consul:latest command: agent -dev -client=0.0.0.0 ports: - "8500:8500" consul-telemetry-collector: image: hashicorp/consul-telemetry-collector:latest volumes: - ./otel-config.yaml:/etc/otel/config.yaml environment: - CONSUL_ADDR=[***] - OTEL_EXPORTER_OTLP_ENDPOINT=[***] - LOG_LEVEL=info depends_on: - consul-agent ports: - "8889:8889" # Prometheus指标暴露端口 otel-collector: image: otel/opentelemetry-collector-contrib:latest volumes: - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml ports: - "4317:4317" # OTLP gRPC接收端口
| 环境变量名 | 描述 | 默认值 |
|---|---|---|
CONSUL_ADDR | Consul Agent服务地址 | http://localhost:8500 |
OTEL_EXPORTER_OTLP_ENDPOINT | OTLP协议导出端点 | http://localhost:4317 |
LOG_LEVEL | 日志级别(debug/info/warn/error) | info |
CONFIG_PATH | 配置文件路径 | /etc/otel/config.yaml |
COLLECTION_INTERVAL | 数据采集间隔(如"10s") | 10s |
通过挂载配置文件(推荐)自定义采集规则,典型配置结构如下:
yamlreceivers: consul: endpoint: ${CONSUL_ADDR} # 从环境变量获取Consul地址 collection_interval: ${COLLECTION_INTERVAL} # 采集间隔 metrics: include: ["consul.service.*", "consul.client.*"] # 包含指标 exclude: ["consul.debug.*"] # 排除调试指标 processors: batch: # 批量处理优化网络传输 timeout: 2s send_batch_size: 1024 filter: # 过滤特定指标 metrics: include: metric_names: ["consul.service.health", "consul.client.rpc"] exporters: otlp: # 导出至OTLP后端 endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT} tls: insecure: true # 开发环境禁用TLS验证 prometheus: # 导出至Prometheus endpoint: ":8889" # 暴露Prometheus指标端点 metric_expiration: 12h service: pipelines: metrics: receivers: [consul] processors: [batch, filter] exporters: [otlp, prometheus]
prometheus导出器暴露端点(如:8889)yamlscrape_configs: - job_name: 'consul-telemetry' static_configs: - targets: ['consul-telemetry-collector:8889']
通过OTLP协议对接Grafana Cloud:
yamlexporters: otlp/grafana: endpoint: "otlp-gateway-prod-us-central-0.grafana.net:4317" headers: authorization: "Basic <base64-encoded-api-key>"
telemetry配置段调整)collection_interval减少采集频率,或调整batch处理器参数--memory=256m --cpus=0.5
manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务