ES资源深入分析

监控工具

Elasticsearch的监控工具(如/_cat/nodes、/_cluster/health、/_nodes/stats等API)来监控集群的性能指标,包括CPU使用率。根据监控结果调整资源配置和线程池设置。

curl $(kubectl -nqfusion get svc elasticsearch-logging --no-headers | awk '{print $3}'):9200/_cat/nodes?v
curl $(kubectl -nqfusion get svc elasticsearch-logging --no-headers | awk '{print $3}'):9200/_cluster/health?pretty
curl $(kubectl -nqfusion get svc elasticsearch-logging --no-headers | awk '{print $3}'):9200/_nodes/stats?pretty > es-stats.txt
more es-stats.txt

/_nodes/stats

/_nodes/stats API提供了关于Elasticsearch节点的详细统计信息,包括CPU、内存、垃圾回收(GC)、线程池、网络请求、索引操作等。以下是主要关心的指标及其含义:

CPU

  • cpu.percent:CPU使用率百分比,反映节点的CPU负载,过高可能导致性能问题。
  • cpu.load_1m/5m/15m:分别表示过去1分钟、5分钟、15分钟的平均CPU负载,用于评估CPU使用趋势。

内存

  • mem.heap_used_percent:堆内存使用率百分比,反映JVM堆内存使用情况,过高可能导致GC频繁或内存不足。
  • mem.heap_committed:已分配的堆内存大小。
  • mem.heap_max:JVM堆内存的最大值。
  • mem.non_heap_used_percent:非堆内存使用率百分比。

垃圾回收(GC)

  • gc.collectors.young.collection_count:年轻代GC的收集次数,频繁的GC可能影响性能。
  • gc.collectors.young.collection_time_in_millis:年轻代GC的收集耗时(毫秒)。
  • gc.collectors.old.collection_count:老年代GC的收集次数。
  • gc.collectors.old.collection_time_in_millis:老年代GC的收集耗时(毫秒)。

网络请求

  • http.current_open:当前打开的HTTP连接数。
  • transport.server_open:当前打开的传输层连接数。
  • transport.rx_count/tx_count:接收和发送的传输层请求次数。
  • transport.rx_size_in_bytes/tx_size_in_bytes:接收和发送的数据量(字节)。

索引操作

  • indices.docs.count:索引中文档的总数。
  • indices.store.size_in_bytes:索引存储的总大小(字节)。
  • indices.indexing.index_total:索引操作的总次数。
  • indices.indexing.index_time_in_millis:索引操作的总耗时(毫秒)。
  • indices.search.query_total:查询操作的总次数。
  • indices.search.query_time_in_millis:查询操作的总耗时(毫秒)。

线程池

  • thread_pool.search.queue:搜索线程池的队列长度,过长可能表明搜索请求积压。
  • thread_pool.index.queue:索引线程池的队列长度。
  • thread_pool.bulk.queue:批量操作线程池的队列长度。
  • thread_pool.write.queue:写入操作线程池的队列长度。

文件系统(可选)

  • fs.total.total_in_bytes:文件系统的总大小(字节)。
  • fs.total.free_in_bytes:文件系统中空闲的空间(字节)。
    -fs .total.available_in_bytes:文件系统中可用的空间(字节)。

在监控时,重点关注CPU使用率、堆内存使用率、GC频率、索引操作性能和线程池队列长度等指标,这些关键指标有助于及时发现和解决性能瓶颈。

按照大小排序

curl $(kubectl -nqfusion get svc elasticsearch-logging --no-headers | awk '{print $3}'):9200/_cat/indices?v&s=store.size:desc
curl $(kubectl -n qfusion get svc elasticsearch-logging --no-headers | awk '{print $3}'):9200/_cat/indices &> /tmp/elasticsearch-check$(date +'%Y-%m-%d_%H-%M').txt
awk '{print $3}' /tmp/elasticsearch-check$(date +'%Y-%m-%d_%H-%M').txt | sort -t '.' -k 5,5n -k 7,7n -k 9,9n > /tmp/sorted_output$(date +'%Y-%m-%d_%H-%M').txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值