Prometheus介绍
Prometheus 是一个开源的系统监控和警报工具包,最初由 SoundCloud 开发,现在是一个独立的开源项目,并且是云原生计算基金会(CNCF)的一部分。Prometheus 以其强大的数据模型和灵活的查询语言(PromQL)而闻名,广泛用于监控微服务架构、容器化环境(如 Kubernetes)以及传统的单体应用。
官网:https://prometheus.io/
下载网址:https://prometheus.io/download/
核心组件
- prometheus
- grafana
- alertmanager
- blackbox_exporter
- node_exporter
查看系统的架构
【Linux】来查看当前系统的架构-CSDN博客
我这里是的版本是ARMv8 CPU
选择对应版本
下载prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.53.2/prometheus -2.53.2.linux-arm64.tar.gz
下载alertmanager
wget https://github.com/prometheus/alertmanager/releases/download/v0.27.0/alertmanager-0.27.0.linux-arm64.tar.gz
下载blackbox_exporter
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.25.0/blackbox_exporter-0.25.0.linux-arm64.tar.gz
下载node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-arm64.tar.gz
下载mysqld_exporter
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.1/mysqld_exporter-0.15.1.linux-arm64.tar.gz
下载grafana
官网地址:Download Grafana | Grafana Labs
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_11.3.0-77262_77262_linux_arm64.tar.gz
创建目录
mkdir -pv /software
mkdir -pv /usr/local/prometheus
mkdir -pv /data/app_logs
解压prometheus
tar -zxvf prometheus-2.53.2.linux-arm64.tar.gz -C /usr/local/prometheus/
重命名prometheus
mv prometheus-2.53.2.linux-arm64 prometheus-2.53.2
启动prometheus
nohup ./prometheus --web.enable-admin-api --web.enable-lifecycle --config.file=prometheus_new.yml >>/data/app_logs/prometheus.log 2>&1 &
解压alertmanager
tar -zxvf /software/alertmanager-0.27.0.linux-arm64.tar.gz -C /usr/local/prometh eus/
重新命名alertmanager
mv alertmanager-0.27.0.linux-arm64 alertmanager-0.27.0
启动alertmanager
nohup ./alertmanager --config.file=alertmanager.yml >>/data/app_logs/alertmanager.log 2>&1 &
解压和重命名node_exporter
tar -zxvf /software/node_exporter-1.8.2.linux-arm64.tar.gz -C /usr/loca l/prometheus/mv node_exporter-1.8.2.linux-arm64 node_exporter-1.8.2
启动node_exporter
nohup ./node_exporter --web.listen-address http://127.0.0.1:9000/data/ap
p_logs/node_exporter.log 2>&1 &
解压和重命名grafana
tar -zxvf /software/grafana-enterprise_11.3.0-77262_77262_linux_arm64.tar.gz -C
/usr/local/prometheus/mv grafana-11.3.0-77262 grafana-11.3.0
创建grafana系统服务
vim /usr/lib/systemd/system/grafana-server.service
编辑内容:
[Unit]
Description=Grafana
After=network.target[Service]
Type=notify
ExecStart=/usr/local/prometheus/grafana-11.3.0/bin/grafana-server -homepath /usr/local/prometheus/grafana-11.3.0
Restart=always # 设置为总是重启[Install]
WantedBy=multi-user.target
启动服务
systemctl start grafana-server.service
设置开机自启动
systemctl enable grafana-server.service