服务器监控

docker 监控(服务端)

cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息。
Grafana 是一个开源的度量分析和可视化系统

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=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
View Code

主机监控

安装node_exporter

node_exporter.sh

#!/bin/bash

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 <<EOF >/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
View Code

 

数据存储

Docker部署: https://prometheus.io/docs/prometheus/latest/installation/
配置

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=<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: ['192.168.31.62:8080']

  - job_name: "Linux"
    static_configs:
    - targets: ['192.168.31.62:9100']
View Code

 

 

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

 

数据展示

https://github.com/google/cadvisor
https://grafana.com/grafana/download
Docker主机监控模板: 193
Linux主机监控模板: 9276
账号密码默认admin

docker run -d \
--name=grafana \
-p 3000:3000 \
grafana/grafana
View Code

公共模板地址 

https://grafana.com/grafana/dashboards/

 k8s  监控 Kubernetes Capacity Planning Dashboard

 

posted @ 2020-10-02 10:17  jiuchen  阅读(290)  评论(0编辑  收藏  举报