docker简化部署有状态prometheusgrafana

目录

【docker简化部署有状态prometheus+grafana】

docker pull grafana/grafana:latest
docker pull prom/prometheus:latest

例如/home/urname

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.
alerting:
  alertmanagers:
  - static_configs:
    - targets:
rule_files:
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090'] # 监控prometheus自己
  - job_name: 'agent-node'
    static_configs:
    - targets: ['localhost:9100']
  - job_name: 'target-service-1' # 目标服务
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
    - targets: ['xx.xx.xx.xx:19999']
  - job_name: 'target-service-2' # 多个目标服务
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
    - targets: ['yy.yy.yy.yy:99991']
docker volume create prometheus-data
docker run \
    -p 9090:9090 \
    -v /home/urname/prometheus.yml:/etc/prometheus/prometheus.yml \
    -v prometheus-data:/prometheus \
    prom/prometheus
docker run --restart=unless-stopped -d --name=grafana -p 3000:3000 grafana/grafana