prometheus +grafana 配置安装(不一定正确,需安装自己环境配置)

环境:

系统centos 7.6    

192.168.30.31   master   

192.168.30.32    node
#安装prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.27.1/prometheus-2.27.1.linux-amd64.tar.gz
tar -xf prometheus-2.27.1.linux-amd64.tar.gz
mv prometheus-2.27.1.linux-amd64 /usr/local
ln -s /usr/local/prometheus-2.27.1.linux-amd64/ /usr/local/prometheus
useradd -s /sbin/nologin -M prometheus
mkdir /data/prometheus -p
chown -R prometheus:prometheus /usr/local/prometheus/
chown -R prometheus:prometheus /data/prometheus/

vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus
Restart=on-failure
[Install]
WantedBy=multi-user.target

vim /usr/local/prometheus-2.27.1.linux-amd64/prometheus.yml
********************************
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['192.168.30.31:9090']
- job_name: 'node1'
static_configs:
- targets: ['192.168.30.32:9100']
*************************************************

systemctl start prometheus
systemctl status prometheus
systemctl enable prometheus
# 安装grafana
wget https://dl.grafana.com/oss/release/grafana-6.5.0-1.x86_64.rpm
yum localinstall grafana-6.5.0-1.x86_64.rpm
systemctl start grafana-server && systemctl enable grafana-server

# 安装node_export(两台机器都要master 和node 都要安装)
wget https://github.com/prometheus/node_exporter/releases/download/v1.1.1/node_exporter-1.1.1.linux-amd64.tar.gz
tar -xf node_exporter-1.1.1.linux-amd64.tar.gz
mv node_exporter-1.1.1.linux-amd64 node_exporter
cd node_exporter

vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=nflow
ExecStart=/opt/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target

systemctl start node_exporter
systemctl enable node_exporter

#curl http://localhost:9100/metrics 测试是否正常

访问 IP:3000 进入grafana  的页面

访问 IP:9090 进入prometheus 的页面

上一篇:C语言在STM32中的内存分配


下一篇:Windows网络编程——查询本机的主机名称及IP地址(控制台应用程序)