prometheus 监控ElasticSearch核心指标
ES监控方案
本文主要讲述使用 Prometheus监控ES,梳理核心监控指标并构建 Dashboard ,当集群有异常或者节点发生故障时,可以根据性能图表以高效率的方式进行问题诊断,再对核心指标筛选添加告警。
根据《How to monitor Elasticsearch performance》一文中的介绍:
Elasticsearch本身提供了大量的指标,可以帮助我们进行故障预检,并在遇到诸如节点不可用、JVM OutOfMemoryError和垃圾回收时间过长等问题时采取必要措施。 通常需要监控的几个关键领域是:
- 查询和索引(indexing)性能
- 内存分配和垃圾回收
- 主机级别的系统和网络指标
- 集群健康状态和节点可用性
- 资源饱和度和相关错误
梳理promethues官方的提供的ElasticSearch exporter提供的核心metrics监控以上关键领域
集群健康和节点可用性
通过cluster healthAPI可以获取集群的健康状况,可以把集群的健康状态当做是集群平稳运行的重要信号,一旦状态发生变化则需要引起重视;API返回的一些重要参数指标及对应的prometheus监控项如下
返回参数 | 备注 | metric name |
---|---|---|
status | 集群状态,green( 所有的主分片和副本分片都正常运行)、yellow(所有的主分片都正常运行,但不是所有的副本分片都正常运行)red(有主分片没能正常运行) | elasticsearch_cluster_health_status |
number_of_nodes/number_of_data_nodes | 集群节点数/数据节点数 | elasticsearch_cluster_health_number_of_nodes/data_nodes |
active_primary_shards | 活跃的主分片总数 | elasticsearch_cluster_health_active_primary_shards |
active_shards | 活跃的分片总数(包括复制分片) | elasticsearch_cluster_health_active_shards |
relocating_shards | 当前节点正在迁移到其他节点的分片数量,通常为0,集群中有节点新加入或者退出时该值会增加 | elasticsearch_cluster_health_relocating_shards |
initializing_shards | 正在初始化的分片 | elasticsearch_cluster_health_initializing_shards |
unassigned_shards | 未分配的分片数,通常为0,当有节点的副本分片丢失该值会增加 | elasticsearch_cluster_health_unassigned_shards |
number_of_pending_tasks | 只有主节点能处理集群级元数据的更改(创建索引,更新映射,分配分片等),通过pending-tasks API可以查看队列中等待的任务,绝大部分情况下元数据更改的队列基本上保持为零 |
elasticsearch_cluster_health_number_of_pending_tasks |
依据上述监控项,配置集群状态Singlestat面板,健康状态一目了然
主机级别的系统和网络指标
metric name | description |
---|---|
elasticsearch_process_cpu_percent | Percent CPU used by process CPU使用率 |
elasticsearch_filesystem_data_free_bytes | Free space on block device in bytes 磁盘可用空间 |
elasticsearch_process_open_files_count | Open file descriptors ES进程打开的文件描述符 |
elasticsearch_transport_rx_packets_total | Count of packets receivedES节点之间网络入流量 |
elasticsearch_transport_tx_packets_total | Count of packets sentES节点之间网络出流量 |
如果CPU使用率持续增长,通常是由于大量的搜索或索引工作造成的负载。可能需要添加更多的节点来重新分配负载。
文件描述符用于节点间的通信、客户端连接和文件操作。如果打开的文件描述符达到系统的限制(一般Linux运行每个进程有1024个文件描述符,生产环境建议调大65535),新的连接和文件操作将不可用,直到有旧的被关闭。
如果ES集群是写负载型,建议使用SSD盘,需要重点关注磁盘空间使用情况。当segment被创建、查询和合并时,Elasticsearch会进行大量的磁盘读写操作。
节点之间的通信是衡量群集是否平衡的关键指标之一,可以通过发送和接收的字节速率,来查看集群的网络正在接收多少流量。
JVM内存和垃圾回收
metric name | description |
---|---|
elasticsearch_jvm_gc_collection_seconds_count | Count of JVM GC runs垃圾搜集数 |
elasticsearch_jvm_gc_collection_seconds_sum | GC run time in seconds垃圾回收时间 |
elasticsearch_jvm_memory_committed_bytes | JVM memory currently committed by area最大使用内存限制 |
elasticsearch_jvm_memory_used_bytes | JVM memory currently used by area 内存使用量 |
主要关注JVM Heap 占用的内存以及JVM GC 所占的时间比例,定位是否有 GC 问题。Elasticsearch依靠垃圾回收来释放堆栈内存,默认当JVM堆栈使用率达到75%的时候启动垃圾回收,添加堆栈设置告警可以判断当前垃圾回收的速度是否比产生速度快,若不能满足需求,可以调整堆栈大小或者增加节点。
搜索和索引性能
搜索请求
metric name | description |
---|---|
elasticsearch_indices_search_query_total | query总数 |
elsticsearch_indices_search_query_time_seconds | query时间 |
elasticsearch_indices_search_fetch_total | fetch总数 |
elasticsearch_indices_search_fetch_time_seconds | fetch时间 |
索引请求
metric name | description |
---|---|
elasticsearch_indices_indexing_index_total | Total index calls索引index数 |
elasticsearch_indices_indexing_index_time_seconds_total | Cumulative index time in seconds累计index时间 |
elasticsearch_indices_refresh_total | Total time spent refreshing in second refresh时间 |
elasticsearch_indices_refresh_time_seconds_total | Total refreshess refresh数 |
elasticsearch_indices_flush_total | Total flushes flush数 |
elasticsearch_indices_flush_time_seconds | Cumulative flush time in seconds累计flush时间 |
将时间和操作数画在同一张图上,左边y轴显示时间,右边y轴显示对应操作计数,ops/time查看平均操作耗时判断性能是否异常。通过计算获取平均索引延迟,如果延迟不断增大,可能是一次性bulk了太多的文档。
Elasticsearch通过flush操作将数据持久化到磁盘,如果flush延迟不断增大,可能是磁盘IO能力不足,如果持续下去最终将导致无法索引数据。
资源饱和度
metric name | description |
---|---|
elasticsearch_thread_pool_queue_count | Thread Pool operations queued 线程池中排队的线程数 |
elasticsearch_thread_pool_rejected_count | Thread Pool operations rejected 线程池中被拒绝的线程数 |
elasticsearch_indices_fielddata_memory_size_bytes | Field data cache memory usage in bytes fielddata缓存的大小 |
elasticsearch_indices_fielddata_evictions | Evictions from filter cache fielddata缓存的驱逐次数 |
elasticsearch_indices_filter_cache_memory_size_bytes | Filter cache memory usage in bytes 过滤器高速缓存的大小 |
elasticsearch_indices_filter_cache_evictions | Evictions from filter cache 过滤器缓存的驱逐次数 |
elasticsearch_cluster_health_number_of_pending_tasks | Cluster level changes which have not yet been executed 待处理任务数 |
elasticsearch_indices_get_missing_total | Total get missing 丢失文件的请求数 |
elasticsearch_indices_get_missing_time_seconds | Total time of get missing in seconds 文档丢失的请求时间 |
通过采集以上指标配置视图,Elasticsearch节点使用线程池来管理线程对内存和CPU使用。可以通过请求队列和请求被拒绝的情况,来确定节点是否够用。
每个Elasticsearch节点都维护着很多类型的线程池。一般来讲,最重要的几个线程池是搜索(search),索引(index),合并(merger)和批处理(bulk)。
每个线程池队列的大小代表着当前节点有多少请求正在等待服务。一旦线程池达到最大队列大小(不同类型的线程池的默认值不一样),后面的请求都会被线程池拒绝。
prometheus 监控ElasticSearch核心指标的更多相关文章
- Prometheus监控elasticsearch集群(以elasticsearch-6.4.2版本为例)
部署elasticsearch集群,配置文件可"浓缩"为以下: cluster.name: es_cluster node.name: node1 path.data: /app/ ...
- Prometheus监控node-exporter常用指标含义
一.说明 最近使用Prometheus新搭建监控系统时候发现内存采集时centos6和centos7下内存监控指标采集计算公式不相同,最后采用统一计算方法并整理计算公式如下: 1 100-(node_ ...
- prometheus 监控elasticsearch
1.安装: 如果有elk单独用户,切换到该用户下, wget下载,进入到es安装目录,执行 ./elasticsearch-plugin install file://$(pwd)/../../ela ...
- 基于 prometheus 的微服务指标监控
基于prometheus的微服务指标监控 服务上线后我们往往需要对服务进行监控,以便能及早发现问题并做针对性的优化,监控又可分为多种形式,比如日志监控,调用链监控,指标监控等等.而通过指标监控能清晰的 ...
- Kubernetes 监控:Prometheus Adpater =》自定义指标扩缩容
使用 Kubernetes 进行容器编排的主要优点之一是,它可以非常轻松地对我们的应用程序进行水平扩展.Pod 水平自动缩放(HPA)可以根据 CPU 和内存使用量来扩展应用,前面讲解的 HPA 章节 ...
- Kubernetes 系列(五):Prometheus监控框架简介
由于容器化和微服务的大力发展,Kubernetes基本已经统一了容器管理方案,当我们使用Kubernetes来进行容器化管理的时候,全面监控Kubernetes也就成了我们第一个需要探索的问题.我们需 ...
- Prometheus 监控领域最锋利的“瑞士军刀”
原文:https://mp.weixin.qq.com/s/Cujn6_4w8ZcXCOWpoAStvQ 一.Kubernetes 容器监控的标配—Prometheus 1.简介 Prometheus ...
- Kubernetes集群部署史上最详细(二)Prometheus监控Kubernetes集群
使用Prometheus监控Kubernetes集群 监控方面Grafana采用YUM安装通过服务形式运行,部署在Master上,而Prometheus则通过POD运行,Grafana通过使用Prom ...
- Prometheus监控学习笔记之Prometheus不完全避坑指南
0x00 概述 Prometheus 是一个开源监控系统,它本身已经成为了云原生中指标监控的事实标准,几乎所有 k8s 的核心组件以及其它云原生系统都以 Prometheus 的指标格式输出自己的运行 ...
随机推荐
- OSI七层模型对应功能及协议
前言 OSI七层模型:纯理论模型,所有实际设备和协议都不能对应理论模型. 每一层对应着实际的设备 物理层:中继器.集线器.双绞线 数据链路层:网桥.以太网交换机.网卡 网路层:路由器.三层交换机 传输 ...
- PAT(B) 1043 输出PATest(Java)统计
题目链接:1043 输出PATest (20 point(s)) 题目描述 给定一个长度不超过 104 的.仅由英文字母构成的字符串.请将字符重新调整顺序,按 PATestPATest- 这样的 ...
- Nginx的启动、停止等命令
Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍.1.启 ...
- Django中ORM多对多表的操作
自己创建第三张表建立多对多关系 表的创建 # 老师表和学生表可以是一个多对多的关系,建表时可以手动建立第三张表建立关联 class Student(models.Model): name = mode ...
- 回忆一下Node(随时更改,想到什么写什么)
什么是Node? Node.js 是一个基于Chrome V8 引擎的JavaScript运行环境 Node.js使用了一个事件驱动.非阻塞式I/O的模型,使其轻量又高效 事件驱动: 任务执行,发布者 ...
- java利用反射打印出类的结构
1 输入一个类名:java.lang.String将打印出String类定义的结构,例如: public final class java.lang.String { public java.lang ...
- 从客户发送http请求到服务器返回http之间发生了什么
由于我知识有限,可能会有模糊或者错误的地方,欢迎讨论与指正. 1.浏览器发出http请求 当用户访问一个url时,浏览器便会开始生成一个http请求. 首先获取http请求中所需要的参数,如url,c ...
- selenium异常
记一下让我花时间去找解决办法的异常 org.openqa.selenium.ElementNotInteractableException: element not interactable 第一次出 ...
- Python 一些内置函数的总结~~~~
1. type() 两种用法 a. 当传入参数为一个时,返回值为参数的类型 b. 当传入参数为三个时,type(name, bases, dict) name: 类名 bases: 继承父类的元组,可 ...
- iveiw DatePicker 只能选择本月之前的日期,本月包括之后都不能选择
日期判断只能选择本月之前的日期 <DatePicker type="date" :options="options3" format="yyyy ...