elasticseach集群添加prometheus监控

news/2025/10/31 17:40:46/文章来源:https://www.cnblogs.com/chengshaoting/p/19180750

elastic集群监控配置

我的集群是普通的版本 并不是pod 因为业务量不稳定时高时低 配置越复杂维护程度越高,企业招聘就越难。
并没有去grafana上去配置数据源信息 图形界面之类的东西 我们的目的是想给这个在以前的基础上加一个钉钉告警。
前一段时间业务量大 swap分区被占用了5个G 简单地刷新swap并没有把数据刷到磁盘 过一会又满了。 经过排查发现是es负载很高,把系统的io速度降到很低 监控疯狂告警 最后修改es和系统内核配置 然后关闭swap分区 才解决了这个问题 当时并没有把es监控起来 现在看来十分有必要 (钉钉告警已经有了 现在是纯配置就完事 )

  • 我的监控版本
    在这里插入图片描述
    各个版本基本上变动不大 应该可以兼容
  1. 上传文件包elasticsearch_exporter-1.1.0.linux-amd64.tar.gz到prometheus主机 并解压

git上的学习地址: https://github.com/justwatchcom/elasticsearch_exporter

  • 先启动elasticsearch_exporter 在终端启动
    es.uri 地址只要有一个就会对整个集群进行监控
    把红框里的配置全部打开
    ./elasticsearch_exporter --help 能查看使用方法 这里面有好多都是默认的 建议反复研读上文连接
    在这里插入图片描述
  ./elasticsearch_exporter --es.uri=http://10.128.128.51:9200 --es.all true --es.cluster_settings true --es.indices true --es.indices_settings true --es.shards true --web.listen-address=:9114无报错之后查看
curl http://127.0.0.1:9114/metrics

开始配置prometheus

  • 找到文件监控规则中的配置
 vim  ../elasticsearch_exporter-1.1.0.linux-amd64/elasticsearch.rules这个文件夹有监控示例,稍作修改即可使用
# calculate filesystem used and free percent
elasticsearch_filesystem_data_used_percent = 100 * (elasticsearch_filesystem_data_size_bytes - elasticsearch_filesystem_data_free_bytes) /elasticsearch_filesystem_data_size_bytes
elasticsearch_filesystem_data_free_percent = 100 - elasticsearch_filesystem_data_used_percent# alert if too few nodes are running
ALERT ElasticsearchTooFewNodesRunningIF elasticsearch_cluster_health_number_of_nodes < 3FOR 5mLABELS {severity="critical"}ANNOTATIONS {description="There are only {{$value}} < 3 ElasticSearch nodes running", summary="ElasticSearch running on less than 3 nodes"}
# alert if heap usage is over 90%
ALERT ElasticsearchHeapTooHighIF elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"} > 0.9FOR 15mLABELS {severity="critical"}ANNOTATIONS {description="The heap usage is over 90% for 15m", summary="ElasticSearch node {{$labels.node}} heap usage is high"}
二进制安装的prometheus目录结构
[root@jmenv ~]# ll prometheus-2.12.0.linux-amd64
total 132308
-rw-r--r--.  1 root root    29214 Aug 25 18:17 1.txt
drwxr-xr-x.  2 3434 3434       38 Aug 18  2019 console_libraries
drwxr-xr-x.  2 3434 3434      173 Aug 18  2019 consoles
drwxr-xr-x. 26 root root     4096 Aug 25 17:00 data
-rw-r--r--.  1 3434 3434    11357 Aug 18  2019 LICENSE
-rw-------.  1 root root    15434 Aug 25 17:49 nohup.out
-rw-r--r--.  1 3434 3434     2770 Aug 18  2019 NOTICE
-rwxr-xr-x.  1 3434 3434 84771664 Aug 18  2019 prometheus
-rw-r--r--.  1 3434 3434     1225 Aug 25 17:36 prometheus.yml
-rwxr-xr-x.  1 3434 3434 50620988 Aug 18  2019 promtool
-rw-r--r--.  1 root root     3822 Aug 25 17:49 rules.txt
-rw-r--r--.  1 root root      402 May 13 15:16 service.json
-rw-r--r--.  1 root root      321 May  7 18:45 service.json.bakprometheus自己有一个监控规则文档  当服务重启时会加载监控规则  将上文中的监控规则按照rule.txt中的格式稍作修改将修改后的文本复制进去,只要变量和配置格式不变的情况下可以自由发挥:  下面就是↓- alert:  es健康节点数小于3expr:  elasticsearch_cluster_health_number_of_nodes < 3for: 5mlabels:status: warningannotations:description: "There are only {{$value}} < 3 ElasticSearch nodes running, summary=ElasticSearch running on less than 3 nodes"- alert:  es占用率高于90%expr:  elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"} > 0.9for: 15mlabels:status: warningannotations:description: "The heap usage is over 90% for 15m, summary=ElasticSearch node {{$labels.node}} heap usage is high"
  • 修改prometheus.yml
[root@jmenv prometheus-2.12.0.linux-amd64]# ll
total 132308
-rw-r--r--.  1 root root    29214 Aug 25 18:17 1.txt
drwxr-xr-x.  2 3434 3434       38 Aug 18  2019 console_libraries
drwxr-xr-x.  2 3434 3434      173 Aug 18  2019 consoles
drwxr-xr-x. 26 root root     4096 Aug 25 17:00 data
-rw-r--r--.  1 3434 3434    11357 Aug 18  2019 LICENSE
-rw-------.  1 root root    15677 Aug 25 18:24 nohup.out
-rw-r--r--.  1 3434 3434     2770 Aug 18  2019 NOTICE
-rwxr-xr-x.  1 3434 3434 84771664 Aug 18  2019 prometheus
-rw-r--r--.  1 3434 3434     1225 Aug 25 17:36 prometheus.yml
-rwxr-xr-x.  1 3434 3434 50620988 Aug 18  2019 promtool
-rw-r--r--.  1 root root     3822 Aug 25 17:49 rules.txt
-rw-r--r--.  1 root root      402 May 13 15:16 service.json
-rw-r--r--.  1 root root      321 May  7 18:45 service.json.bakvim  prometheus.yml  #添加一个job
# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:- localhost:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:# - "first_rules.yml"- "/root/prometheus-2.12.0.linux-amd64/rules.txt"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
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: ['localhost:9090']- job_name: 'service-node_export'file_sd_configs:- files:- /root/prometheus-2.12.0.linux-amd64/service.jsonrefresh_interval: 10s- job_name: 'elasticsearch'scrape_interval: 30sstatic_configs:- targets:- 127.0.0.1:9114
其中- targets:  127.0.0.1:9114 是我启动的es的export地址与端口
  • 修改 prometheus.yml 局部

prometheus-2.12.0.linux-amd64/prometheus.yml
添加job_name
```bash
- job_name: 'elasticsearch'scrape_interval: 30sstatic_configs:- targets:- 127.0.0.1:9114

热重启prometheus

 nohup ./prometheus --web.enable-lifecycle &
curl -XPOST http://localhost:9090/-/reload 

如果热重启失效直接kill掉重启也行

kill  -9 $(ss  -lntup |grep  9090|awk -F'=' '{print $2}' |awk -F',' '{print $1}')
然后去prometheus目录下重启就行

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/952054.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

智驭增长,睿见未来:哲讯科技,以SAP Business One铸就成长型企业的数字脊梁

在当今这个瞬息万变的商业世界里,每一个雄心勃勃的成长型企业都面临着同样的核心课题:如何在混乱的数据中建立秩序?如何在繁杂的业务中洞察本质?又如何在不确性的市场中预见未来?答案,已然清晰——数字化转型已非…

2025年叠步楼梯公司排名前十推荐:选购指南与行业洞察

摘要 叠步楼梯作为一种解构主义设计元素,近年来在建筑和室内设计行业中迅速崛起,通过错位或重叠的设计创造出动态视觉效果,不仅提升空间美感,还巧妙利用下方空间实现多功能区域。行业数据显示,2025年全球定制楼梯…

【干货】一键生成MySQL配置文件

【干货】一键生成MySQL配置文件关键代码如下: <!DOCTYPE html> <html lang="zh-CN"> <head><meta charset="UTF-8"><meta name="viewport" content="…

系统运维面试题

基础 选择6块1T硬盘做完raid50后,可供使用内存有多大? 解析: raid50备份方案为两组RAID5组成RAID0,做raid 5阵列所有磁盘容量必须一样大,当容量不同时,会以最小的容量为准。 最好硬盘转速一样,否则会影响性能,而…

2025 年隔音门厂家最新推荐榜,技术实力与市场口碑深度解析,精选适配多场景的优质品牌

据建筑装饰协会 2024 年度声学建材测评报告显示,国内隔音门市场合格率仅为 78.3%,超两成产品存在隔音量不达标、密封性能差等问题。为帮助消费者与企业精准筛选优质产品,本次推荐榜以 “技术参数 + 实际应用 + 售后…

ELK日志收集分析工具解析

@目录1、工作当中日志的重要性2、日志收集的工具有那些Solr与es的对比与选型ElasticSearch vs Solr总结3、elk简单介绍4、倒排查询原理5、数据的分类6、es用户场景Elasticsearch简介7、部署es的方法8、和es交互的方式8…

ansible的硬件巡检脚本

使用场景: 公司内部服务器用的是云厂商的, 一般在交付使用前会给一个配置清单 但是真正的配置还需要运维部门的人员去检查一下 每批交付使用的主机少则十几台 多则几十台 将配置的结果做成表格导进execl 我相信没有…

2025年vr虚拟体验馆制造企业权威推荐榜单:vr虚拟体验馆/vr体验馆设备/vr设备体验馆源头厂家精选

VR虚拟体验馆作为沉浸式娱乐与教育的重要载体,正随着全球虚拟现实技术的成熟而快速增长。据行业数据显示,2025年中国VR产业规模预计突破1000亿元,其中体验馆相关设备与内容市场占比约30%,年增长率稳定在15%以上。V…

【251031】CF2155 Div.2 vp 总结

题目梗概题目编号 题目名称 题目链接A El fucho LinkB Abrahams Great Escape LinkC The Ancient Wizards Capes LinkD Batteries LinkE Mimo & Yuyu LinkF Juans Colorful Tree Link给的都是 VJ 的链接,带翻译。…

nmap简单用例

@目录下载对目标主机的所有端口扫描对目标主机指定端口进行扫描扫描内网整个网段主机nmap是一个端口扫描工具 与telnet不同的是 它可以扫描指定主机的所有开放端口(内网) 多一个工具就多一份快乐 下面来介绍一些基…

新能源汽车焊接智能节气阀

在新能源汽车产业迅猛发展的浪潮中,制造工艺的优劣直接关系到车辆的性能、安全与市场竞争力。焊接,作为新能源汽车生产流程里的关键一环,无论是构建车身框架,还是连接电池模组,其质量的好坏都起着决定性作用。而在…

数仓分层介绍

@目录数仓分层的意义是什么?常见的数据分层ODS层: 源数据层DW层: 数据仓库层(也叫作集团数据中心)DA(app)层: 数据应用层更加细分的数仓分层方案1 ODS数据源2 DW数据仓库2.1 DWD明细层:2.2 DWB基础数据层:2.3 DWS服…

2025年单向平衡阀批发厂家权威推荐榜单:双向电磁阀/旋挖机多路阀/电磁阀线圈源头厂家精选

在工业流体控制领域,单向平衡阀作为关键控制元件,其市场规模持续扩大,2024年全球市场份额已突破320亿元,预计2025年将保持8%-10%的稳健增长。 单向平衡阀凭借其精确的流量控制、稳定的压力平衡和可靠的反向截止特性…

互信脚本使用

yum install -y expect ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa export mypass=123456name=(node1 node2 node3 node4) for i in ${name[@]};do expect -c " spawn ssh-copy-id -i /root/.ssh/i…

如何查看软件包名

1、输出当前手机上的全部app包名 首先都需要连击上手机,手机上打开开发者模式,cmd中输入adb devices查看当前手机连接状态 输出device就说明手机连接成功了,device前面就是连接的这个手机的设备号 adb shell pm lis…

数学求和公式c++ - miao

1. 等差数列求和 // 首项a1,末项an,项数n ll arithmetic_sum(ll a1, ll an, ll n) {return n * (a1 + an) / 2; }// 首项a1,公差d,项数n ll arithmetic_sum(ll a1, ll d, ll n) {return n * a1 + n * (n - 1) / 2 …

李宏毅机器学习笔记16 - 教程

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

通过编写systemctl来控制二进制部署的MySQL服务

自己给自己看的 其他人做为参考[root@node1 ~]# vim /usr/lib/systemd/system/mysqld.service [Unit] Description=MySQL Documentation=https://www.mysql.com/cn/ # 依赖服务,仅当依赖的服务启动之后再启动自定义…

无法定位程序输入点于kernel32.dll?详解原因与5种有效修复方案

运行程序时弹出“无法定位程序输入点于动态链接库 KERNEL32.dll 上”的错误提示?这是 Windows 系统常见的兼容性或系统文件异常问题。本文从原理、成因到具体解决步骤,带你逐步排查问题源头,并提供 5 种可行方案(含…

普法学习: 劳动关系的认定

@目录1 什么是劳动关系1.2 劳动关系的认定标准1.3 从属性标准也是认定劳动关系的一种2. 案例2.1 案例摘要2.2 案例简述 1 什么是劳动关系[1]劳动关系是劳动者与用人单位之间实现社会化劳动的过程中产生的社会关系,对劳…