简体   繁体   中英

Configure Prometheus for monitoring multiple microservices

I want to monitor a Spring Boot Microservices application running on Docker-Compose with about 20 microservices with Prometheus and Grafana .

What is the best approach:
1- Having one job with multiple targets for each microservice?

scrape_configs:
  - job_name: 'services-job'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['service-one:8080']
        labels:
          group: 'service-one' 
      - targets: ['service-two:8081']
        labels:
          group: 'service-two' 

2- Having multiple jobs with single target for each service?

scrape_configs:
  - job_name: 'service-one-job'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['service-one:8080']
        labels:
          group: 'service-one'
  - job_name: 'service-two-job'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['service-two:8081']
        labels:
          group: 'service-two'  
 

The way you group your targets by job has nothing to do with the number of endpoints to scrape.

You need to group all the targets with the same purpose in the same job. That's exactly what the documentation says :

A collection of instances with the same purpose, a process replicated for scalability or reliability for example, is called a job.

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