[toc]
部署prometheus
官网: https://prometheus.io/docs/prometheus/latest/getting_started/
关闭selinux及防火墙
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld.service
systemctl disable firewalld.service
下载安装包及部署
# 下载安装包
wget https://github.com/prometheus/prometheus/releases/download/v2.9.2/prometheus-2.9.2.linux-amd64.tar.gz
# 解压安装包
tar zxvf prometheus-2.9.2.linux-amd64.tar.gz
# 移动到/usr/local/目录
mv prometheus-2.9.2.linux-amd64 /usr/local/prometheus
# 进入prometheus目录
cd /usr/local/prometheus/
# 将prometheus配置为系统服务
cat > /usr/lib/systemd/system/prometheus.service << EOF
[Unit]
Description=prometheus
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml \
--storage.tsdb.path=/data/prometheus \
--web.external-url=http://192.168.1.155:9090 \
--web.max-connections=512
[Install]
WantedBy=multi-user.target
EOF
# 启动prometheus
mkdir /data/prometheus
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
# 检查启动端口
ss -nplt|grep 9090
LISTEN 0 128 :::9090 :::* users:(("prometheus",pid=24513,fd=6))
# 查看进程
ps -ef |grep promethe|grep -v grep
root 24513 1 0 07:18 ? 00:00:00 /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus --web.external-url=http://0.0.0.0:9090 --web.max-connections=512
访问web界面
- alerts用于配置报警信息,监控报警规则等
- graph图形,可以写promeQL,用来查询数据
- status
- runtime information 查看当前基础环境,配置
- command-line flags 命令行日志
- configuration 当前prometheus的配置及配置文件
- rules 角色,用来定义监控指标的告警规则
- targets 当前已经被监控的对象
- service discovery 服务发现,可以动态配置监控目标