热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

实体源码方式搭建Prometheus+node并注册为系统systemctl服务+基础grafana模板导入使用

#安装Prometheus#!binbash#防止报错先删除用户和目录userdelprometheusrm-rfvarlibprometheusrm-rfusrlocal

# 安装Prometheus

#!/bin/bash# 防止报错先 删除用户和目录
userdel prometheus
rm -rf /var/lib/prometheus
rm -rf /usr/local/prometheus/#下载解压
#wget https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz
tar zxvf prometheus-2.12.0.linux-amd64.tar.gz
mv prometheus-2.12.0.linux-amd64 /usr/local/prometheus#创建用户
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/prometheus# 创建systemd服务
cat > /etc/systemd/system/prometheus.service <[Unit]
Description&#61;prometheus
After&#61;network.target
[Service]
Type&#61;simple
User&#61;prometheus
ExecStart&#61;/usr/local/prometheus/prometheus --config.file&#61;/usr/local/prometheus/prometheus.yml --storage.tsdb.path&#61;/var/lib/prometheus/data
Restart&#61;on-failure
[Install]
WantedBy&#61;multi-user.target
EOF# 启动Prometheus
systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus
systemctl enable prometheus

# 安装 node_exporter 

#!/bin/bash# 防止报错先 删除用户和目录
userdel prometheus
rm -rf /var/lib/prometheus
rm -rf /usr/local/prometheus/
rm -rf /usr/local/node_exporter#下载解压
#wget https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz
mv node_exporter-0.18.1.linux-amd64 /usr/local/node_exporter#创建用户
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/prometheus# 创建systemd服务
cat > /etc/systemd/system/node_exporter.service <[Unit]
Description&#61;node_exporter
After&#61;network.target
[Service]
Type&#61;simple
User&#61;prometheus
ExecStart&#61;/usr/local/node_exporter/node_exporter
Restart&#61;on-failure
[Install]
WantedBy&#61;multi-user.target
EOF# 启动node_exporter
systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter
systemctl status node_exporter

# 查看配置文件    

grep -v "#" /usr/local/prometheus/prometheus.yml |grep -v "^$"

global:
alerting:alertmanagers:- static_configs:- targets:
rule_files:
scrape_configs:- job_name: &#39;node&#39;static_configs:- targets:- &#39;10.69.15.78:9100&#39;- &#39;10.69.15.67:9100&#39;- &#39;10.69.15.30:9100&#39;- &#39;10.69.15.20:9100&#39;- &#39;10.69.15.21:9100&#39;

# grafana使用模板   linux 9276    docker使用  193   附 监控docker 插件和命令  暂未测试

# 推荐漂亮容器模板 8919


推荐阅读
author-avatar
ScorpIo斡
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有