promethues 集成eureka 服务发现
prometheus 从v2.22 开始支持基于eureka的服务发现配置了(内置),对于基于eureka 的spring cloud
微服务解决方案的监控就很方便了,以下是一个简单的试用
环境准备
- docker-compose 文件
version: "3"
services:
g:
image: grafana/grafana
ports:
- "3000:3000"
p:
image: prom/prometheus
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
- prometheus.yml 配置
global:
scrape_interval: 10s
evaluation_interval: 10s
scrape_configs:
- job_name: eureka
metrics_path: /metrics
eureka_sd_configs:
- server: <your eureka address>/eureka
启动&&效果
- 启动
docker-compose up -d
- 效果
因为我使用本机,访问的是k8s部署的eureka 服务,所有状态是down
说明
当然一个好消息是VictoriaMetrics 的vmagent 也是支持eureka的服务发现的
参考资料
https://github.com/prometheus/prometheus/blob/release-2.23/documentation/examples/prometheus-eureka.yml
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#eureka_sd_config
https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.48.0