1.安装包
链接:https://pan.baidu.com/s/1McvL1t0-YpCuZ-IX-d8jQA
提取码:vy9h
--来自百度网盘超级会员V3的分享
一.prometheus
2.解压
3.准备工作
cp prometheus promtool /usr/local/bin/ mkdir -p /etc/prometheus/ cp prometheus.yml /etc/prometheus/
4.查看版本
prometheus --version
prometheus.yml:
scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['192.168.92.111:9090'] # 添加 PushGateway 监控配置 - job_name: 'pushgateway' static_configs: - targets: ['192.168.92.111:9091'] labels: instance: pushgateway # 添加 Node Exporter 监控配置 - job_name: 'node exporter' static_configs: - targets: ['192.168.92.111:9100', '192.168.92.112:9100', '192.168.92.113:9100']
5.添加系统服务
vim /etc/systemd/system/prometheus.service
将以下内容写入文件中
[Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple ExecStart=/usr/local/bin/prometheus --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml Restart=on-failure [Install] WantedBy=multi-user.target
6.启动服务,设置开机自启,并检查服务开启状态
systemctl daemon-reload
systemctl enable prometheus
7.启动服务
systemctl start prometheus
8.检测服务状态
systemctl status prometheus
二.pushgateway
1.配置开机自启动
vim /etc/systemd/system/prometheus.service
加入以下内容和上面一样就是改了这个运行文件
ExecStart=/usr/local/bin/pushgateway------》指定文件里的可执行文件就行,我的是把他拎出来放bin目录下了
[Unit] Description=pushgateway Documentation=https:https://github.com/prometheus/pushgateway
After=network.target
[Service] Type=simple ExecStart=/usr/local/bin/pushgateway #pushgateway解压路径,
Restart=on-failure
[Install] WantedBy=multi-user.target
2.启动服务,设置开机自启,并检查服务开启状态
systemctl daemon-reload
systemctl enable pushgateway
3.启动服务
systemctl start pushgatway
systemctl status pushgatway
三.node_exporter
vim /etc/systemd/system/node_exporter.service
加入:(ExecStart=node_exporter解压后的可执行文件,9100的端口号得加上,#!/bin/bash脚本标识好像是)
#!/bin/bash [Unit] Description=node_exporter Documentation=node_exporter Monitoring System After=network.target [Service] ExecStart=/usr/local/bin/node_exporter/node_exporter –web.listen-address=:9100\ [Install] WantedBy=multi-user.target
2.启动服务,设置开机自启,并检查服务开启状态
systemctl daemon-reload systemctl enable node_exporter
3.启动服务
systemctl start node_exporter
systemctl status node_exporter
grafana的安装配置
参考:https://www.cnblogs.com/sanduzxcvbnm/p/13606261.html
4.检测