在使用過程中,發現docker拉取prometheus的時候默認使用的國外的鏡像源,特別慢,於是網上查了下,可以按照如下方式配置國內鏡像源,嘗試了下,果然快多了。
一、配置國內鏡像源
編輯 vi /etc/docker/daemon.json,如果文件沒有可以 touch 新建一個。
{
"registry-mirrors": ["http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn"]
}
重啟 docker
systemctl restart docker
其他國內鏡像源:
Docker中國區官方鏡像
https://registry.docker-cn.com
網易
http://hub-mirror.c.163.com
ustc
https://docker.mirrors.ustc.edu.cn
中國科技大學
https://docker.mirrors.ustc.edu.cn
二、安裝並運行Promethues
(1)下載安裝promethues的docker鏡像
docker pull prom/prometheus:latest
(2)運行promethues
docker run -itd -p 9090:9090 --name=prometheus -v \
/etc/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
三、監控Linux性能指標
修改promethues配置文件(建議藍色內容直接拷貝)
vi /etc/promethues.yml
# my global config
global:
# 設置抓取數據的時間間隔,間隔設置為每15秒一次。默認為每1分鍾。
scrape_interval: 15s
# 設定抓取數據的超時時間,默認為10s
scrape_timeout: 5s
# 設置規則刷新,每15秒刷新一次規則。默認值為每1分鍾。
evaluation_interval: 15s
# 監控報警配置(需要額外安裝 alertmanager組件)
#alerting:
# alertmanagers:
# - static_configs:
# 設定alertmanager和prometheus交互的接口,即alertmanager監聽的ip地址和端口
# - targets: ["k8s.dev-share.top:9093"]
# 報警規則文件
#rule_files:
# - '/home/deploy/alertmanager/rules/*.yml'
# 普羅米修斯與抓取模塊交互的接口配置
scrape_configs:
# 一定要全局唯一, 采集 遠程linux的 metrics
- job_name: linux
static_configs:
- targets: ['192.168.100.100:9100']
labels:
instance: linux
參考:
https://blog.csdn.net/xiaobinqt/article/details/116139871
https://mp.weixin.qq.com/s/KTqXmofI99AzE-GeSFjutA
