监控

prometheus普罗米修斯监控docker容器

2022-03-18  本文已影响0人  王宣成
vim /home/prometheus/prometheus.yml
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=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"
  
  # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9090']
  
    
  - job_name: 'docker'
    static_configs:
    - targets: ['localhost:8080']
docker run \
   --volume=/:/rootfs:ro \
   --volume=/var/run:/var/run:ro \
   --volume=/sys:/sys:ro \
   --volume=/var/lib/docker/:/var/lib/docker:ro \
   --volume=/dev/disk/:/dev/disk:ro \
   --volume=/cgroup:/cgroup:ro \
   --privileged=true \
   --publish=8080:8080 \
   --detach=true \
   --name=cadvisor \
   google/cadvisor
docker run -d --name=prometheus -p 9090:9090 -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest
docker run -d \
  -p 3000:3000 \
  --restart=always \
  --name=grafana \
  -e "GF_SECURITY_ADMIN_PASSWORD=admin" \
  -e "GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource,raintank-worldping-app,grafana-piechart-panel" \
  grafana/grafana

http://127.0.0.1:3000/ 默认账号:admin 密码:admin

添加数据源


image.png image.png
image.png

导入


image.png
image.png image.png
image.png
上一篇 下一篇

猜你喜欢

热点阅读