所需容器如下
Prometheus Server(普罗米修斯监控主服务器 ) Node Exporter (收集Host硬件和操作系统信息) cAdvisor (负责收集Host上运行的容器信息) Grafana (展示普罗米修斯监控界面)
docker run -d -p 9100:9100 \ -v "/proc:/host/proc" \ -v "/sys:/host/sys" \ -v "/:/rootfs" \ -v "/etc/localtime:/etc/localtime" \ prom/node-exporter \ --path.procfs /host/proc \ --path.sysfs /host/sys \ --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
部署后执行docker ps -a
查看容器状态
root@Synology:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d49e898538ed prom/node-exporter "/bin/node_exporter …" 2 days ago Up 2 days 0.0.0.0:9100->9100/tcp agitated_hoover
docker run -d -v "/etc/localtime:/etc/localtime" \ --volume=/:/rootfs:ro \ --volume=/volume1/homes/docker_conf:/var/run:rw \ --volume=/sys:/sys:ro \ --volume=/volume1/homes/docker_conf/var/lib/docker/:/var/lib/docker:ro \ --publish=18104:8080 \ --detach=true \ --name=cadvisor \ --privileged=true \ google/cadvisor:latest
部署后执行docker ps -a
查看容器状态
root@Synology:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8f457d3ad48f google/cadvisor:latest "/usr/bin/cadvisor -…" 2 days ago Up 2 days 0.0.0.0:18104->8080/tcp cadvisor
此处我将docker映射的相关东西都放在了/volume1/homes/docker_conf
可用参考
root@Synology:/volume1/homes/docker_conf# 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=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: #监听的地址 - targets: ['192.168.10.200:9090','192.168.10.200:18104','192.168.10.200:9100']
docker run -d \ -v /volume1/homes/docker_conf/prometheus.yml:/etc/prometheus/prometheus.yml \ -v "/etc/localtime:/etc/localtime" \ --name prometheus \ --publish=9090:9090 \ prom/prometheus:latest
部署后执行docker ps -a
查看容器状态
root@Synology:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 01ea6fe3ff19 prom/prometheus:latest "/bin/prometheus --c…" 2 days ago Up 2 days 0.0.0.0:9090->9090/tcp prometheus
docker run -d -i -p 3000:3000 \ -v "/etc/localtime:/etc/localtime" \ -e "GF_SERVER_ROOT_URL=http://grafana.server.name" \ -e "GF_SECURITY_ADMIN_PASSWORD=admin8888" \ --net=host \ grafana/grafana
部署后执行docker ps -a
查看容器状态
root@Synology:~# docker ps -a 7c2e4f420ebe grafana/grafana "/run.sh" 2 days ago Up 2 days gallant_spence
浏览器访问群晖IP:3000 按照网上步骤添加Prometheus数据源,添加面板
推荐好用的面板:https://grafana.com/grafana/dashboards/8919