美文网首页ELK stackelasticsearch大数据女娲
[Elasticsearch Monitor] 如何监控Elas

[Elasticsearch Monitor] 如何监控Elas

作者: king_wang | 来源:发表于2017-02-13 10:16 被阅读227次

    上一篇文章如何监控Elasticsearch主要描述了对于Es服务器应该监控哪些指标。本文旨在介绍es api中的各统计指标含义。

    Elasticsearch’s RESTful API + JSON

    默认情况下,Elasticsearch在9200端口上提供了restful http服务,返回集群,节点,索引状况的JSON结果。主要有五个HTTP REST API可用于监视Elasticsearch:

    • Cluster Health API
    • Cluster Stats API
    • Node Stats API
    • Index Stats API
    • Pending Tasks API

    下面的表格总结了上一篇文章中提到搜索性能,索引性能,内存性能,网络性能对应的ES API。其中有些性能数据是从多个维度描述的,比如搜索性能在节点维度和索引维度都有提供。

    Metric category Availability
    Search performance metrics Node Stats API, Index Stats API
    Indexing performance metrics Node Stats API, Index Stats API
    Memory and garbage collection Node Stats API, Cluster Stats API
    Network metrics Node Stats API
    Cluster health and node availability Cluster Health API
    Resource saturation and errors Node Stats API, Index Stats API, Cluster Stats API, Pending Tasks API

    (一)Cluster Health API

    Cluster Health API提供了描述集群健康状态的JSON对象数据。

    API接口:

    GET _cluster/health
    

    返回结果JSON:

    {
      "cluster_name": "elasticsearch",
      "status": "yellow",
      "timed_out": false,
      "number_of_nodes": 1,
      "number_of_data_nodes": 1,
      "active_primary_shards": 11,
      "active_shards": 11,
      "relocating_shards": 0,
      "initializing_shards": 0,
      "unassigned_shards": 10,
      "delayed_unassigned_shards": 0,
      "number_of_pending_tasks": 0,
      "number_of_in_flight_fetch": 0,
      "task_max_waiting_in_queue_millis": 0,
      "active_shards_percent_as_number": 52.38095238095239
    }
    
    • status一共有3个状态:green表示所有主分片及备份分片都分配好了,集群100%健康。yellow表示所有主分片都分配好了,但至少有一个备份分片未分配。数据没有丢失,搜索结果是完整的。但高可用性会缺失,存在丢失数据风险,以黄色表示警告。red表示至少有一个主分片未分配,并且这个主分片的所有分片都丢失了。数据已经丢失了,搜索结果不完整,并且往这个分片索引数据会发生异常。
    • number_of_nodesnumber_of_data_nodes,从名字就可以知道分别是节点数和数据节点数。
    • active_primary_shards,集群中所有index的主分片数量的总和。
    • active_shards,集群中所有index的分片数量的总和,包括备份分片。
    • relocating_shards,正在被移动的分片数量。通常为0,在集群rebalance的时候会有变化。

    (二)Cluster Stats API

    Cluster Stats API提供了集群维度的信息。基本上是Node Stats API的数据的总和。虽然没有每个节点的详细信息,但是可以让你快速了解掌握整个集群当前的运行状态。

    API接口:

    GET _cluster/stats
    
    {
      "_nodes": {
        "total": 1,
        "successful": 1,
        "failed": 0
      },
      "cluster_name": "elasticsearch",
      "timestamp": 1500175210218,
      "status": "yellow",
      "indices": {
        "count": 11,
        "shards": {...},
        "docs": {...},
        "store": {...},
        "fielddata": {...},
        "query_cache": {...},
        "completion": {...},
        "segments": {...}
      },
      "nodes": {
        "count": {...},
        "versions": [...],
        "os": {...},
        "process": {...},
        "jvm": {...},
        "fs": {...},
        "plugins": [...],
        "network_types": {...}
      }
    }
    

    对于indices和nodes内部属性的含义会在Node Stats API里介绍

    (三)Node Stats API

    Node Stats API是一个非常有用的API,用于监控集群每台服务器的状态。它统计了我们想要监控的主要的那些指标,包括了我们上一篇列举的大部分指标。

    API接口:

    GET _nodes/stats (或者指定node获取 _nodes/node1,node2/stats)
    
    {
      "_nodes": {
        "total": 1,
        "successful": 1,
        "failed": 0
      },
      "cluster_name": "elasticsearch",
      "nodes": {
        "SdRLvOO7RKSiaBW_hmwvZg": {
          "name": "node1",
          "indices": {...},
          "os": {...},
          "process": {...},
          "jvm": {...},
          "thread_pool": {...},
          "fs": {...},
          "transport": {...},
          "http": {...}
        }
        ...
      }
    }
    
    • 查询性能指标,前缀indices.search.*的指标
      • indices.search.query_total 查询总量
      • indices.search.query_time_in_millis 查询总耗时
      • indices.search.query_current 正在处理的查询量
      • indices.search.fetch_total 查询的第二阶段fetch总量
      • indices.search.fetch_time_in_millis fetch耗时
      • indices.search.fetch_current 正在处理的fetch数量
    • 索引性能指标,前缀indices.indexing.* ,indices.refresh.* ,indices.flush.* 的指标
      • indices.indexing.index_total 索引总量
      • indices.indexing.index_time_in_millis 索引耗时
      • indices.indexing.index_current 正在处理的索引量
      • indices.refresh.total 刷新内存总量
      • indices.refresh.total_time_in_millis 刷新内存耗时
      • indices.flush.total 同步磁盘总量
      • indices.flush.total_time_in_millis 同步磁盘耗时
    • Cache性能指标,前缀indices.query_cache.* ,indices.fielddata.* ,indices.request_cache.* 的指标。fielddata可能会成为内存消耗大户,需要特别注意
      • indices.query_cache.memory_size_in_bytes 查询缓存大小
      • indices.query_cache.evictions 查询缓存剔除大小
      • indices.fielddata.memory_size_in_bytes fielddata缓存大小
      • indices.fielddata.evictions fielddata缓存剔除大小
      • indices.request_cache.memory_size_in_bytes 所有请求缓存大小
      • indices.request_cache.evictions 所有请求缓存剔除大小
    • os指标
      • os.cpu.percent 系统CPU使用百分比
      • os.cpu.load_average.1m 系统CPU 1分钟平均load
      • os.cpu.load_average.5m 系统CPU 5分钟平均load
      • os.cpu.load_average.15m 系统CPU 15分钟平均load
      • os.mem.free_percent 系统内存可用百分比
      • os.mem.used_percent 系统内存已使用百分比
      • os.mem.total_in_bytes 系统内存总大小
      • os.mem.free_in_bytes 系统内存可用大小
      • os.mem.used_in_bytes 系统内存已使用大小
      • os.swap.total_in_bytes 系统swap总大小
      • os.swap.free_in_bytes 系统swap可用大小
      • os.swap.used_in_bytes 系统swap已使用大小
    • process指标,专用与es jvm进程的资源消耗指标
      • process.cpu.percent 进程CPU使用百分比
      • process.cpu.total_in_millis 进程CPU使用时间
      • process.mem.total_virtual_in_bytes 进程可用虚拟内存大小
      • process.open_file_descriptors 进程打开文件句柄数
      • process.max_file_descriptors 进程可用句柄数
    • JVM性能指标,前缀jvm.*的指标,内存使用及GC指标
      • jvm.gc.collectors.young.collection_count young gc 大小
      • jvm.gc.collectors.young.collection_time_in_millis young gc 耗时
      • jvm.gc.collectors.old.collection_count old gc 大小
      • jvm.gc.collectors.old.collection_time_in_millis old gc 耗时
      • jvm.mem.heap_used_percent 内存使用百分比
      • jvm.mem.heap_used_in_bytes 内存使用量
      • jvm.mem.heap_committed_in_bytes 内存占用量
    • 线程池性能指标,前缀thread_pool.*的指标
      • thread_pool.bulk.queue thread_pool.index.queue thread_pool.search.queue thread_pool.merge.queue 各队列长度
      • thread_pool.bulk.rejected thread_pool.index.rejected thread_pool.search.rejected thread_pool.merge.rejected 各队列溢出量(未执行,被放弃)
    • 文件系统指标
      • fs.total.total_in_bytes 数据目录总大小
      • fs.total.free_in_bytes 数据目录剩余大小
      • fs.total.vailable_in_bytes 数据目录可用大小
    • 集群通信指标
      • transport.rx_count 集群通信中接收的数据包总数
      • transport.rx_size_in_bytes 集群通信中接收的数据的总大小
      • transport.tx_count 集群通信中发送的数据包总数
      • transport.tx_size_in_bytes 集群通信中发送的数据的总大小
      • transport.server_open 为集群通信打开的连接数

    相关文章

      网友评论

      本文标题:[Elasticsearch Monitor] 如何监控Elas

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