You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于OpenTelemetry Collector将Prometheus指标接入Elastic Cloud

解决方案:在OpenTelemetry Collector内完成Prometheus指标到OTLP/proto的转换

完全可以在OpenTelemetry Collector Agent内部实现Prometheus格式指标到OTLP/proto的转换,不需要额外引入任何代理或独立后端平台,完全符合你所有数据接入Elastic Cloud的需求。

核心原理

OpenTelemetry Collector的Prometheus Receiver在抓取到文本格式的Prometheus指标后,会自动将其转换为OpenTelemetry的标准指标模型,随后你只需要通过OTLP Exporter将转换后的指标以OTLP/proto格式发送到Elastic Cloud即可——整个转换过程完全在Collector内部完成,无需额外步骤。

具体配置示例

以下是一个简化的Collector配置文件(otel-collector-config.yaml),展示如何实现这个流程:

receivers:
  prometheus:
    config:
      scrape_configs:
        # 抓取PostgreSQL的Prometheus指标(假设暴露在9187端口)
        - job_name: "postgresql"
          static_configs:
            - targets: ["postgres-host:9187"]
        # 抓取RabbitMQ的Prometheus指标(假设暴露在15692端口)
        - job_name: "rabbitmq"
          static_configs:
            - targets: ["rabbitmq-host:15692"]
        # 抓取AWS CloudWatch指标(通过CloudWatch Exporter转成Prometheus格式后抓取)
        - job_name: "cloudwatch"
          static_configs:
            - targets: ["cloudwatch-exporter-host:9106"]

exporters:
  otlp:
    endpoint: "<你的Elastic Cloud OTLP端点,例如:abc123.apm.us-east-1.aws.cloud.es.io:443>"
    headers:
      Authorization: "ApiKey <你的Elastic Cloud API密钥>"
    tls:
      insecure: false

service:
  pipelines:
    metrics:
      receivers: [prometheus]
      exporters: [otlp]

关键注意事项

  • Elastic Cloud OTLP配置:需在Elastic Cloud控制台获取对应的OTLP端点和API密钥,确保exporters.otlp.endpoint和Authorization头配置正确。
  • CloudWatch指标处理:AWS CloudWatch原生不暴露Prometheus端点,可使用官方cloudwatch-exporter将CloudWatch指标转换为Prometheus格式,再通过Collector的Prometheus Receiver抓取。
  • 定制应用适配:定制应用直接推送OTLP/proto指标到Collector即可,只需在receivers中添加otlp receiver,并将其加入metrics pipeline。

这样配置后,所有Prometheus格式的指标都会被Collector抓取、转换为OTLP/proto格式,最终统一发送到Elastic Cloud,完全满足你“无额外组件、全数据接入Elastic”的需求。

内容的提问来源于stack exchange,提问作者Ryan.Bartsch

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 05:52:47