docker安装Prometheus+cAdvisor+Grafana

修改yml文件,加上docker和linux机器设备

docker run -d --name=prometheus  -p 9090:9090  -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml  prom/prometheus

配置文件信息

[root@k8s-master tmp]# cat prometheus.yml 
# 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'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: "docker"
    static_configs:
    - targets: ['172.16.254.151:8082']

  - job_name: "Linux"
    static_configs:
    - targets: ['172.16.254.150:9100','172.16.254.151:9100','172.16.254.149:9100']

页面访问验证
http://172.16.254.151:9090/targets

image.png

Docker部署cAdvisor:

docker run -d \
--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 \
--publish=8082:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest

页面访问验证:
http://172.16.254.151:8082/metrics

image.png

linux 主机添加

cat node_exporter.sh
wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
tar zxf node_exporter-0.17.0.linux-amd64.tar.gz
mv node_exporter-0.17.0.linux-amd64 /usr/local/node_exporter

cat </usr/lib/systemd/system/node_exporter.service
[Unit]
Description=https://prometheus.io

[Service]
Restart=on-failure
ExecStart=/usr/local/node_exporter/node_exporter

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable node_exporter
systemctl restart node_exporter

Docker部署Grafana:

docker run -d --name=grafana -p 3000:3000  grafana/grafana

页面访问验证(admin/admin):
http://172.16.254.151:3000/d/Bkl9bBYik/linuxzhu-ji-jian-kong?orgId=1

image.png

cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息。

Grafana 是一个开源的度量分析和可视化系统。

https://github.com/google/cadvisor
https://grafana.com/grafana/download

导入Docker主机监控模板:193

Linux主机监控模板:9276(操作步骤一样)

image.png
image.png
image.png

你可能感兴趣的:(docker安装Prometheus+cAdvisor+Grafana)