springcloud集成prometheus(待完善)

1、准备

1.1 下载prometheus
1.2 下载grafana
1.3 项目地址:https://gitee.com/zhou1124/bat

启动三个项目

1.1 eureka-server
1.2 prometheus
1.3 eureka-client

3 prometheus配置

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'prometheus'
  - job_name: 'node_exporter'
  - job_name: redis_exporter
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
    - targets: ['localhost:9100']
    - targets: ['localhost:9121']    
  - job_name: 'bat-eureka-server'
    scheme: http
    metrics_path: '/actuator/prometheus'
    consul_sd_configs:
    #consul 地址
      - server: '127.0.0.1:9091'
        scheme: http
        #注意名称大写 因为eureka名称大写
        services: [PROMETHEUS,EUREKACLIENT]

#####3.1 查看状态
springcloud集成prometheus(待完善)_第1张图片

###4、grafana添加仪表盘
springcloud集成prometheus(待完善)_第2张图片
仪表盘id: https://grafana.com/grafana/dashboards/10280

4.1 结果

springcloud集成prometheus(待完善)_第3张图片

你可能感兴趣的:(java)