zl程序教程

您现在的位置是:首页 >  云平台

当前栏目

搭建Grafana+Prometheus监控平台

监控平台 搭建 Prometheus Grafana
2023-06-13 09:11:39 时间

本文采用二进制源码安装方式,安装环境如下

操作系统

Grafana版本

Prometheus版本

Alibaba Cloud Linux 3

8.5.4

2.36.0

1、安装Prometheus

release地址:https://github.com/prometheus/prometheus/releases

#下载Prometheus二进制包
wget  https://ghproxy.com/https://github.com/prometheus/prometheus/releases/download/v2.36.0/prometheus-2.36.0.linux-amd64.tar.gz
tar xf prometheus-2.36.0.linux-amd64.tar.gz  -C /opt/
mv /opt/prometheus-2.36.0.linux-amd64 /opt/prometheus

#将prometheus添加至systemd管理
cat << eof >> /etc/systemd/system/prometheus.service
[Unit]
Description=logging prometheus service
Documentation=https://prometheus.io

[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/prometheus/prometheus  --web.enable-lifecycle --config.file=/opt/prometheus/prometheus.yml
Restart=on-failure

[Install]
WantedBy=multi-user.target
eof
systemctl daemon-reload
systemctl start prometheus.service
systemctl enable prometheus.service
  • prometheus默认监听在9090端口,安全组与防火墙放行后可以直接访问:http://IP:9090/gragh 进行访问

2、安装Grafana面板

官方release:https://grafana.com/grafana/download

wget https://dl.grafana.com/oss/release/grafana-8.5.4.linux-amd64.tar.gz
tar -zxvf grafana-8.5.4.linux-amd64.tar.gz  -C /opt/
mv /opt/ grafana-8.5.4/ /opt/grafana
mkdir /opt/grafana/data
sed -i 's/data\/plugins/plugins-bundled/g'    /opt/grafana/conf/defaults.ini
#将grafana添加至systemd管理
cat << eof >> /etc/systemd/system/grafana.service
[Unit]
Description=logging Grafana service
Documentation=https://grafana.com/

[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/grafana/bin/grafana-server  --homepath /opt/grafana/  web
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
eof
systemctl  daemon-reload
systemctl  start grafana.service
systemctl  enable  grafana.service
  • grafana默认监听在3000端口,可以访问:http://IP:3000 进行访问,默认用户密码是:admin

3、添加Prometheus数据源

  • 导入Prometheus默认的监控大屏