美文网首页
prometheus-监控搭建---部署中

prometheus-监控搭建---部署中

作者: 李哈哈_2c85 | 来源:发表于2021-07-13 16:29 被阅读0次

k8s部署已经完成:https://www.jianshu.com/p/a8f66c4aeee7

Prometheus的介绍放于文章底部,参考官网介绍和自己理解。官网:https://prometheus.io/docs/introduction/overview/
https://prometheus.io/download/ --下载地址

1、两种部署方式

1、通过tar包直接部署
————1、服务端组件-prometheus-2.28.1
————2、可视化组件-grafana-8.0.5--模板Node Exporter Full 16
————3、客户端采集组件-exporter-1.1.2
————4、报警组件-alertmanager-0.22.2
————5、pushgateway组件-基本不用(主要用于收集一些短期的 jobs,由于这类 jobs 存在时间较短,可能在 Prometheus 来 Pull 之前就消失了。官方对 什么时候该使用 Pushgateway 有一个很好的说明)
2、通过docker方式部署

1、tar包部署

——1、下载prometheus-2.28.1.linux-amd64.tar.gz包---服务端组件

#安装服务端,主配置文件为prometheus.yml  
#配置文件中global块控制 Prometheus 服务器的全局配置;rule_files块指定 Prometheus 服务器加载的任何规则的位置;
#scrape_configs控制 Prometheus 监控的资源-默认通过http协议监控了自己。

wget https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.linux-amd64.tar.gz
tar -zxvf prometheus-2.28.1.linux-amd64.tar.gz
cd prometheus-2.28.1.linux-amd64/
./prometheus --config.file=prometheus.yml                  #后台启动  nohup /data/prometheus-2.28.1.linux-amd64/prometheus --config.file=/data/prometheus-2.28.1.linux-amd64/prometheus.yml &
#浏览器访问ip:9090   加/metrics可以看到收集自己的数据---(临时查询使用,后面基本是不用的,官方都推荐可视化使用[Grafana]来做)
#后台启动方式并不好,不方便查看状态和控制,建议把他配置成服务,开机启动参考文章:https://www.cnblogs.com/fatyao/p/11007357.html

——2、之后我们来安装可视化组件---[Grafana]--为了方便我直接使用yum安装了
这是官方下载和各种系统安装方式:https://grafana.com/grafana/download?platform=linux

wget https://dl.grafana.com/oss/release/grafana-8.0.5-1.x86_64.rpm
sudo yum install grafana-8.0.5-1.x86_64.rpm
systemctl daemon-reload
systemctl enable grafana-server && systemctl start grafana-server
#默认配置文件位于/etc/grafana/grafana.ini  ip:3000  默认账号密码 admin/admin
#汉化链接:https://www.cnblogs.com/dalianpai/p/13678847.html 提前把.bashrc中alias cp='cp -i'前加上"#"注释重新登录;cp完成后去掉注释重新登录

配置数据源、添加上prometheusURL、导入模板图形


添加数据源 添加URL,access模式内网互通就默认,不互通选用浏览器方式 导入prometheus图形模板,就不看了也没啥意思,后面可以自己看下,之后我们看下node_exporter的模板那个带劲

——3、安装客户端采集组件-exporter(各种不同服务也有各种不同的采集工具,Node_exporter收集机器的系统数据,这里采用prometheus官方提供的exporter,除node_exporter外,官方还提供consul,memcached,haproxy,mysqld等exporter,具体可查看官网。),下载地址同上prometheus官网下载地址

#下载、解压、运行、默认使用的9100端口
wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
tar -zxvf node_exporter-1.1.2.linux-amd64.tar.gz
nohup ./node_exporter &    #后面更新添加为服务配置开机启动
#客户端添加完成后在服务端prometheus.yml中加上监控任务(就是下方job部分) ,重新启动服务端加载配置文件
- job_name: 'node'
    static_configs:
    - targets: ['192.168.5.18:9100']
    - targets: ['192.168.5.19:9100']
(服务端-不重启服务加载配置命令:netstat -nltp | grep 9090 |awk '{print $7}'|awk -F/ '{print $1}'|xargs kill -HUP)通过kill -HUP +进程号

客户端和服务端配置完成,在grafana中加入node监控模板下载地址:https://grafana.com/grafana/dashboards/1860 (就下载16版本的,我用最新版本有的参数不显示,可能跟node_exporter采集器不配套,一些采集的参数指标可能不一样,导致很多仪表没有数据)

别问中文怎么来的-google翻译 把下载的文件导入进去 选择数据来源为prometheus,我上面的报错是因为已经有一个uid相同的模板了 ok就有数据了r1就是5.18的主机名

——4、报警组件-alertmanager-0.22.2

#配置文件为alertmanager.yml
wget https://github.com/prometheus/alertmanager/releases/download/v0.22.2/alertmanager-0.22.2.linux-amd64.tar.gz
tar -zxvf alertmanager-0.22.2.linux-amd64.tar.gz
nohup ./alertmanager &

————————————————————————————————————
服务部署基本完成:接下来配置报警和规则
转到另一篇微信报警:

image.png
https://www.cnblogs.com/wangshuyang/p/11641316.html (参考文档)

相关文章

  • prometheus-监控搭建---部署中

    k8s部署已经完成:https://www.jianshu.com/p/a8f66c4aeee7[https://...

  • Prometheus-监控-Kubernetes

    https://github.com/camilb/prometheus-kuberneteshttps://gi...

  • influxdb+grafana 简单搭建监控系统

    简单搭建监控系统 基础环境: 安装k2-compose 下载监控系统部署模版另存为k2-compose.yml,或...

  • Prometheus-部署Grafana

      Grafana是一个开源的度量分析与可视化套件。经常被用作基础设施的时间序列数据和应用程序分析的可视化,我们这...

  • 策略PM入门学习(三)

    2.3 【实例】效果监控系统搭建 网页搜索中图片类特型结果的监控体系 2.4 【实例】策略监控系统搭建 小结:...

  • ansible部署zabbix监控系统

    1、搭建zabbix服务,实现监控linux和windows的内存,cpu,磁盘,网络等基础指标 zabbix部署...

  • 小记:mestricbeat监控docker容器与宿主机服务

    由于生产环境的搭建部署,我们需要一套对于docker服务的监控。在网上已经翻阅了很多docker监控的方案,由于我...

  • zabbix 部署计划

    1、整理zabbix server 安装文档,总结搭建环境的异常处理。(完成) 2、部署监控一台windows 主...

  • 第十七周作业

    1、搭建zabbix服务,实现监控linux和windows的内存,cpu,磁盘,网络等基础指标 1.部署lnmp...

  • 第十八周

    1、搭建zabbix服务,实现监控linux和windows的内存,cpu,磁盘,网络等基础指标 1.部署lnmp...

网友评论

      本文标题:prometheus-监控搭建---部署中

      本文链接:https://www.haomeiwen.com/subject/kswrpltx.html