简体   繁体   中英

Does Prometheus scrapes 1 pod on Kubernetes?

I installed my Spring Boot application with 2 or 3 pods on Kubernetes in Linux Server. And to monitor it, I installed Prometheus, too. Currently, the metrics from application to Prometheus go very well.

But I suspect that Prometheus takes metrics from only one pod. With a job like below in Prometheus config file, does prometheus takes metrics only from one pod? How can I make Prometheus scrape all pods in same time?

- job_name: 'SpringBootPrometheusDemoProject'
  metrics_path: '/SpringBootPrometheusDemoProject/actuator/prometheus'
  scrape_interval: 5s
  static_configs:
  - targets: ['127.0.0.1:8080']

Yes. In this case, you have to add few annotations in your pod (if it does not exist already) and use kubernetes_sd_configs instead of static_configs .

You will find an example here: https://github.com/appscode/third-party-tools/blob/master/monitoring/prometheus/builtin/README.md#kubernetes-pod

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM