如何使用Prometheus监控Elastic APM Server?求最佳实现方案
用Prometheus监控Elastic APM Server的可行方案
1. 利用Elastic APM Server原生Prometheus指标端点
这是最直接且官方支持的方案——Elastic APM Server从7.10版本开始内置了Prometheus兼容的指标暴露功能:
- 修改APM Server的配置文件
apm-server.yml,启用Prometheus端点:prometheus.enabled: true prometheus.host: ":8200" # 可自定义端口,避免与其他服务冲突 - 重启APM Server后,访问
http://<apm-server-ip>:8200/metrics即可获取标准Prometheus格式的指标,所有指标以apm_server_为前缀,覆盖服务运行状态、事件处理速率、队列积压情况等核心监控维度。 - 在Prometheus配置文件中添加对应的scrape任务:
scrape_configs: - job_name: 'apm-server' static_configs: - targets: ['<apm-server-ip>:8200']
2. 通过MetricBeat转发指标到Prometheus
如果已经在用MetricBeat采集其他数据,或需要对指标进行额外加工,可以通过MetricBeat将APM Server指标转发至Prometheus:
- 先按官方指引配置MetricBeat的
apm模块,完成APM Server指标采集。 - 修改MetricBeat的输出配置,添加Prometheus Remote Write输出:
output.prometheus: hosts: ["<prometheus-ip>:9090/api/v1/write"] # 若Prometheus启用了认证,可添加以下配置 username: "your-username" password: "your-password" - 配置完成后,MetricBeat会将采集到的APM Server指标转换为Prometheus兼容格式,推送到Prometheus存储。
注意事项
- 若使用原生Prometheus端点,需确保APM Server版本不低于7.10;该方案无需额外安装第三方exporter,是官方推荐的非Elastic栈监控路径。
内容的提问来源于stack exchange,提问作者Iryna
相关产品推荐
相关产品推荐

