【Elasticsearch监控】集群查看_python控制elasticsearch怎么查看集群数量

GET /_cluster/allocation/explain
{
  "index": "myindex",
  "shard": 0,
  "primary": false,
  "current_node": "nodeA"       //碎片0当前具有副本的节点                   
}

查询集群中第一个未分配分片解释信息

GET /_cluster/allocation/explain

包含磁盘信息

GET /_cluster/allocation/explain?human&include_disk_info=true

包含决策信息(大量冗余)

GET /_cluster/allocation/explain?include_yes_decisions=true

Node(节点)

Node specification(节点规范说明)

一些集群级命令可以对节点的子集进行操作,可以用节点筛选器指定这些子集。例如,任务管理、节点状态和节点信息都可以报告一组经过筛选的节点的结果,而不是所有节点的结果。

# 没有给出过滤器,默认选择所有节点
GET /_nodes

# 选择所有节点
GET /_nodes/_all

# 选择本地节点
GET /_nodes/_local

# 选择主节点
GET /_nodes/_master

# 通过节点名选择节点,支持通配符
GET /_nodes/node_name_goes_here
GET /_nodes/node_name_goes_*

# 通过IP选择节点,支持通配符
GET /_nodes/10.0.0.3,10.0.0.4
GET /_nodes/10.0.0.*

# 通过角色选择节点
GET /_nodes/_all,master:false
GET /_nodes/data:true,ingest:true
GET /_nodes/coordinating_only:true

# 通过自定义属性选择节点 (e.g. with something like `node.attr.rack: 2` in the configuration file)
GET /_nodes/rack:2
GET /_nodes/ra*:2
GET /_nodes/ra*:2*

master(主节点基本信息)

master没有任何额外的选项。它只是显示主机的节点ID、绑定的IP地址和节点名称。

GET /_cat/master?format=json

响应:

[
  {
    "id" : "B-M3lfhbQfS88kIq64pECQ",
    "host" : "192.168.0.1",
    "ip" : "192.168.0.1",
    "node" : "node02"
  }
]

nodeattrs(节点属性)

nodeattrs命令显示定制的节点属性。

GET /_cat/nodeattrs?v

前几列(节点、主机、ip)为每个节点提供基本信息,attr和value列为自定义节点属性,每行一个。

查看指定属性

GET /_cat/nodeattrs?v&h=name,pid,attr,value

HeaderAliasAppear by DefaultDescriptionExample
nodenameYes节点名称DKDM97B
idnodeIdNo唯一 node IDk0zy
pidpNoProcess ID13061
hosthYesHost namen1
ipiYesIP address127.0.1.1
portpoNo绑定的transport port9300
attrattr.nameYesAttribute namerack
valueattr.valueYesAttribute valuerack123

nodes(节点信息)

显示集群拓扑,各个节点的相关信息

GET /_cat/nodes?v

响应格式

ip          heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.0.1           47          98   1    0.07    0.21     0.17 mdi       *      node02

前几列(ip、heap百分比、ram百分比、cpu、load_*)告诉您节点的位置,并提供性能统计。

最后(node.role、master和name列提供辅助信息,在查看整个集群(尤其是大型集群)时,这些信息通常非常有用。比如我有多少主节点。

是否显示全部ID

GET /_cat/nodes?v&h=id,ip,port,v,m&full_id=true

显示全部字段

GET /_cat/nodes?v&h=*&format=json&human

响应:

[
  {
    "id" : "B-M3",
    "pid" : "3805",
    "ip" : "192.168.0.1",
    "port" : "9300",
    "http_address" : "192.168.0.1:9200",
    "version" : "6.5.0",
    "flavor" : "default",
    "type" : "tar",
    "build" : "816e6f6",
    "jdk" : "1.8.0_241",
    "disk.total" : "147.5gb",
    "disk.used" : "101gb",
    "disk.avail" : "46.5gb",
    "disk.used_percent" : "68.47",
    "heap.current" : "1.3gb",
    "heap.percent" : "46",
    "heap.max" : "2.9gb",
    "ram.current" : "5.6gb",
    "ram.percent" : "97",
    "ram.max" : "5.8gb",
    "file_desc.current" : "26921",
    "file_desc.percent" : "20",
    "file_desc.max" : "131072",
    "cpu" : "3",
    "load_1m" : "0.52",
    "load_5m" : "0.40",
    "load_15m" : "0.26",
    "uptime" : "1.9h",
    "node.role" : "mdi",
    "master" : "*",
    "name" : "node02",
    "completion.size" : "0b",
    "fielddata.memory_size" : "552b",
    "fielddata.evictions" : "0",
    "query_cache.memory_size" : "0b",
    "query_cache.evictions" : "0",
    "request_cache.memory_size" : "1.6kb",
    "request_cache.evictions" : "0",
    "request_cache.hit_count" : "666",
    "request_cache.miss_count" : "2",
    "flush.total" : "1411",
    "flush.total_time" : "311ms",
    "get.current" : "0",
    "get.time" : "162ms",
    "get.total" : "1340",
    "get.exists_time" : "112ms",
    "get.exists_total" : "673",
    "get.missing_time" : "50ms",
    "get.missing_total" : "667",
    "indexing.delete_current" : "0",
    "indexing.delete_time" : "0s",
    "indexing.delete_total" : "0",
    "indexing.index_current" : "0",
    "indexing.index_time" : "1.2m",
    "indexing.index_total" : "1269704",
    "indexing.index_failed" : "0",
    "merges.current" : "0",
    "merges.current_docs" : "0",
    "merges.current_size" : "0b",
    "merges.total" : "164",
    "merges.total_docs" : "2373182",
    "merges.total_size" : "695.8mb",
    "merges.total_time" : "1m",
    "refresh.total" : "5987",
    "refresh.time" : "44.8s",
    "refresh.listeners" : "0",
    "script.compilations" : "4",
    "script.cache_evictions" : "0",
    "search.fetch_current" : "0",
    "search.fetch_time" : "380ms",
    "search.fetch_total" : "4718",
    "search.open_contexts" : "0",
    "search.query_current" : "0",
    "search.query_time" : "865ms",
    "search.query_total" : "4784",
    "search.scroll_current" : "0",
    "search.scroll_time" : "0s",
    "search.scroll_total" : "0",
    "segments.count" : "9606",
    "segments.memory" : "181.2mb",
    "segments.index_writer_memory" : "0b",
    "segments.version_map_memory" : "0b",
    "segments.fixed_bitset_memory" : "1.5mb",
    "suggest.current" : "0",
    "suggest.time" : "0s",
    "suggest.total" : "0"
  }
]

Nodes Stats(节点统计)

允许检索一个或多个(或全部)集群节点的统计信息。

GET /_nodes/stats?human&pretty
GET /_nodes/nodeId1,nodeId2/stats

包含指定信息

GET /_nodes/stats/indices?human&pretty
GET /_nodes/stats/os,process
GET /_nodes/10.0.0.1/stats/process

所有字段:indices、fs、http、jvm、os、process、thread_pool、transport、breaker、discovery、ingest、adaptive_selection(自适应副本的选择,根据设置的副本选择最佳的搜索策略)

文件系统(fs)
GET /_nodes/stats/fs?human&pretty

响应

{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "es65",
  "nodes" : {
    "B-M3lfhbQfS88kIq64pECQ" : {
      "timestamp" : 1603784688049,
      "name" : "node02",
      "transport_address" : "192.168.0.1:9300",
      "host" : "192.168.0.1",
      "ip" : "192.168.0.1:9300",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "attributes" : {
        "ml.machine_memory" : "6256037888",
        "xpack.installed" : "true",
        "ml.max_open_jobs" : "20",
        "ml.enabled" : "true"
      },
      "fs" : {
        "timestamp" : 1603784688049,   //最近一次文件系统统计刷新的时间
        "total" : {
          "total" : "147.5gb",    //文件系统总大小
          "total_in_bytes" : 158399414272,
          "free" : "103.8gb",     //空闲
          "free_in_bytes" : 111544238080,
          "available" : "96.3gb",   //可用
          "available_in_bytes" : 103474397184
        },
        "least_usage_estimate" : {
          "path" : "/opt/elastic/elasticsearch-6.5.0/data/nodes/0",
          "total" : "147.5gb",
          "total_in_bytes" : 158399414272,
          "available" : "96.3gb",
          "available_in_bytes" : 103477952512,
          "used_disk_percent" : 34.672768212191784
        },
        "most_usage_estimate" : {
          "path" : "/opt/elastic/elasticsearch-6.5.0/data/nodes/0",
          "total" : "147.5gb",
          "total_in_bytes" : 158399414272,
          "available" : "96.3gb",
          "available_in_bytes" : 103477952512,
          "used_disk_percent" : 34.672768212191784
        },
        "data" : [   //所有文件存储的列表
          {
            "path" : "/opt/elastic/elasticsearch-6.5.0/data/nodes/0",
            "mount" : "/opt (/dev/sdb)",
            "type" : "ext4",
            "total" : "147.5gb",
            "total_in_bytes" : 158399414272,
            "free" : "103.8gb",
            "free_in_bytes" : 111544238080,
            "available" : "96.3gb",
            "available_in_bytes" : 103474397184
          }
        ],
        "io_stats" : {
          "devices" : [
            {
              "device_name" : "sdb",
              "operations" : 243909,
              "read_operations" : 152239,
              "write_operations" : 91670,
              "read_kilobytes" : 36075760,
              "write_kilobytes" : 5976780
            }
          ],
          "total" : {
            "operations" : 243909,
            "read_operations" : 152239,
            "write_operations" : 91670,
            "read_kilobytes" : 36075760,
            "write_kilobytes" : 5976780
          }
        }
      }
    }
  }
}


内存
GET /_nodes/stats/os?human&pretty

响应

{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "es65",
  "nodes" : {
    "B-M3lfhbQfS88kIq64pECQ" : {
      "timestamp" : 1603784991984,
      "name" : "node02",
      "transport_address" : "192.168.0.1:9300",
      "host" : "192.168.0.1",
      "ip" : "192.168.0.1:9300",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "attributes" : {
        "ml.machine_memory" : "6256037888",
        "xpack.installed" : "true",
        "ml.max_open_jobs" : "20",
        "ml.enabled" : "true"
      },
      "os" : {
        "timestamp" : 1603784991022,
        "cpu" : {
          "percent" : 1,  //最近整个系统的CPU使用量,如果不支持,则为-1
          "load_average" : {  
            "1m" : 0.01,  //系统上的一分钟平均负载(如果一分钟平均负载不可用,则不存在此字段)
            "5m" : 0.03,
            "15m" : 0.05
          }
        },
        "mem" : {
          "total" : "5.8gb",   //物理内存总量
          "total_in_bytes" : 6256037888,
          "free" : "201.3mb",
          "free_in_bytes" : 211091456,
          "used" : "5.6gb",
          "used_in_bytes" : 6044946432,
          "free_percent" : 3,   //可用内存百分比
          "used_percent" : 97
        },
        "swap" : {
          "total" : "819.9mb",   //交换空间总量
          "total_in_bytes" : 859828224,
          "free" : "808.4mb",
          "free_in_bytes" : 847761408,
          "used" : "11.5mb",
          "used_in_bytes" : 12066816
        },
        "cgroup" : {
          "cpuacct" : {
            "control_group" : "/",
            "usage_nanos" : 1549473094112   //同一cgroup中所有任务在Elasticsearch过程中消耗的总CPU时间(以纳秒为单位)
          },
          "cpu" : {
            "control_group" : "/",   //Elasticsearch进程所属的cpu控制组
            "cfs_period_micros" : 100000,  
            "cfs_quota_micros" : -1,
            "stat" : {
              "number_of_elapsed_periods" : 0,
              "number_of_times_throttled" : 0,
              "time_throttled_nanos" : 0
            }
          },
          "memory" : {
            "control_group" : "/",
            "limit_in_bytes" : "9223372036854771712",
            "usage_in_bytes" : "5601808384"
          }
        }
      }
    }
  }
}


进程
GET /_nodes/stats/process?human&pretty

响应

{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "es65",
  "nodes" : {
    "B-M3lfhbQfS88kIq64pECQ" : {
      "timestamp" : 1603785283470,
      "name" : "node02",
      "transport_address" : "192.168.0.1:9300",
      "host" : "192.168.0.1",
      "ip" : "192.168.0.1:9300",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "attributes" : {
        "ml.machine_memory" : "6256037888",
        "xpack.installed" : "true",
        "ml.max_open_jobs" : "20",
        "ml.enabled" : "true"
      },
      "process" : {
        "timestamp" : 1603785283471,
        "open_file_descriptors" : 6789,
        "max_file_descriptors" : 131072,
        "cpu" : {
          "percent" : 4,
          "total" : "23.5m",
          "total_in_millis" : 1412200
        },
        "mem" : {
          "total_virtual" : "43.7gb",  //提供对正在运行的进程可用的虚拟内存的大小
          "total_virtual_in_bytes" : 46930673664
        }
      }
    }
  }
}


索引统计
# fielddata
GET /_nodes/stats/indices/fielddata?human&pretty

# level=indices
GET /_nodes/stats/indices/fielddata?level=indices

# level=shards
GET /_nodes/stats/indices/fielddata?level=shards

# field
GET /_nodes/stats/indices/fielddata?fields=field*

指标名称

支持的指标名称:

  • completion
  • docs
  • fielddata
  • flush
  • get
  • indexing
  • merge
  • query_cache
  • recovery
  • refresh
  • request_cache
  • search
  • segments
  • store
  • translog
  • warmer
搜索组
GET /_nodes/stats?groups=_all
GET /_nodes/stats/indices?groups=foo,bar

Nodes Info

允许检索一个或多个(或全部)集群节点信息。

GET /_nodes
GET /_nodes/nodeId1,nodeId2

基本信息

  "nodes" : {
    "B-M3lfhbQfS88kIq64pECQ" : {
      "name" : "node02",
      "transport_address" : "192.168.0.1:9300",
      "host" : "192.168.0.1",
      "ip" : "192.168.0.1",
      "version" : "6.5.0",
      "build_flavor" : "default",
      "build_type" : "tar",
      "build_hash" : "816e6f6",
      "total_indexing_buffer" : 318636032,
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "attributes" : {
        "ml.machine_memory" : "6256037888",
        "xpack.installed" : "true",
        "ml.max_open_jobs" : "20",
        "ml.enabled" : "true"
      },

其他信息

settings, os, process, jvm,thread_pool, transport, http, plugins, ingest and indices:

GET /_nodes/process

Nodes usage

检索关于每个节点特性使用情况的信息。

GET _nodes/usage
GET _nodes/nodeId1,nodeId2/usage

获取各种操作的使用次数:

{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "es65",
  "nodes" : {
    "B-M3lfhbQfS88kIq64pECQ" : {
      "timestamp" : 1603786339724,
      "since" : 1603763314565,
      "rest_actions" : {
        "nodes_usage_action" : 1,
        "nodes_info_action" : 18336,
        "get_index_template_action" : 347,
        "cat_alias_action" : 8,
        "get_mapping_action" : 347,
        "get_indices_action" : 8,
        "cat_count_action" : 4,
        "nodes_stats_action" : 16,
        "get_all_aliases_action" : 347,
        "cat_snapshot_action" : 3,
        "cat_segments_action" : 6,
        "cat_health_action" : 4,
        "xpack_info_action" : 1535,
        "field_capabilities_action" : 1,
        "cat_fielddata_action" : 24,
        "document_get_action" : 4626,
        "main_action" : 9167,
        "count_action" : 4,
        "cat_templates_action" : 4,
        "cat_recovery_action" : 8,
        "cat_shards_action" : 5,
        "cat_repositories_action" : 1,
        "cat_indices_action" : 12,
        "cat_pending_cluster_tasks_action" : 1,
        "cat_nodes_action" : 15,
        "xpack_monitoring_bulk_action" : 2300,
        "cluster_stats_action" : 2,
        "search_action" : 38305,
        "get_aliases_action" : 2,
        "cat_allocation_action" : 3,
        "cat_master_action" : 1,
        "cat_threadpool_action" : 8,
        "cat_node_attrs_action" : 2
      }
    }
  }
}


Indices (索引)

Indices Stats(索引统计)

索引级统计信息提供关于在索引上发生的不同操作的统计信息。提供了关于索引级别作用域的统计信息(尽管也可以使用节点级别作用域检索大多数统计信息)。

下面返回所有索引的高级聚合和索引级统计信息:

GET /_stats
GET /index1,index2/_stats

默认情况下,会返回所有的统计信息,也可以在URI中指定只返回特定的统计信息。

统计信息分类
指标描述
docs文档/已删除文档(未合并的文档)的数量。注意,受刷新索引的影响。
store索引的大小。
indexing索引统计信息,可以与逗号分隔的types列表结合使用,以提供文档类型级别的统计信息。
get获取get统计信息,包括丢失的统计信息
search搜索统计数据,包括建议统计。您可以通过添加额外的“groups”参数来包含自定义组的统计信息(搜索操作可以与一个或多个组相关联)。“groups”参数接受以逗号分隔的组名称列表。使用’ _all '返回所有组的统计信息。
segments检索开放段的内存使用情况。还可以选择设置’ include_segment_file_size '标志,报告每个Lucene索引文件的磁盘使用情况。
completion完成显示统计数据。
fielddataFielddata统计数据。
flushFlush统计
mergeMerge 统计.
request_cacheShard request cache统计.
refreshRefresh 统计.
warmerWarmer 统计.
translogTranslog 统计.

一些统计数据允许每个字段的粒度,它接受包含字段的逗号分隔列表。默认情况下,包括所有字段:

字段描述
fields要包含在统计数据中的字段列表。除非提供了更具体的字段列表(参见下面),否则将使用此列表作为默认列表。
completion_fields要包含在完成建议统计中的字段列表。
fielddata_fields将包括在Fielddata统计中的字段列表
查询格式
# Get back stats for merge and refresh only for all indices
GET /_stats/merge,refresh
# Get back stats for type1 and type2 documents for the my_index index
GET /my_index/_stats/indexing?types=type1,type2
# Get back just search stats for group1 and group2
GET /_stats/search?groups=group1,group2

返回的统计信息是在索引级别聚合的,包含初选和总聚合,其中初选仅是主分片的值,而total是主分片和复制分片的累计值。

注意,当分片在集群中移动时,它们在其他节点上创建的状态将被清除。另一方面,即使一个分片“保留”了一个节点,该节点仍将保留分片所贡献的统计信息。

分片统计信息

为了获得分片级别统计信息,请将级别参数设置为shards。

GET out-7.7.0-2020.10.29/_stats/merge?level=shards

Indices(查看索引列表)

GET /_cat/indices?v

我们可以很快地知道有多少分片组成一个索引、文档的数量、已删除文档、主存储大小和总存储大小(包括副本在内的所有分片)。所有这些公开的指标都直接来自Lucene。

  • 由于文档和已删除文档的数量都在lucene级别,所以它也包括了所有隐藏文档(比如嵌套文档)。
  • 要在Elasticsearch级别获得实际的文档计数,推荐的方法是使用cat计数或count API
按照索引名排序
GET /_cat/indices?v&s=index

获取黄色索引
GET /_cat/indices?v&health=yellow

获取红色索引
GET /_cat/indices?v&health=red

查看拥有最大数量文档的索引
GET /_cat/indices?v&s=docs.count:desc

获取占用磁盘最大的索引
GET /_cat/indices?v&s=store.size:desc

twitter的分片完成了多少次合并操作?
GET /_cat/indices/twitter?pri&v&h=health,index,pri,rep,docs.count,mt

查看每个索引使用的内存
GET /_cat/indices?v&h=i,tm&s=tm:desc

查询索引相关指标(完全展示)
GET /_cat/indices/out-7.7.0-2020.10.29?pri&v&h=*&format=json


所有字段示例如下
[
  {
    "health" : "yellow",
    "status" : "open",
    "index" : "out-7.7.0-2020.10.29",
    "uuid" : "DSwheo\_eQM2kTblsiVkUMQ",
    "pri" : "5",
    "rep" : "1",
    "docs.count" : "1282748",
    "docs.deleted" : "0",
    "creation.date" : "1603951688411",
    "creation.date.string" : "2020-10-29T06:08:08.411Z",
    "store.size" : "443.1mb",
    "pri.store.size" : "443.1mb",
    "pri.store.size" : "443.1mb",
    "completion.size" : "0b",
    "pri.completion.size" : "0b",
    "pri.completion.size" : "0b",
    "fielddata.memory\_size" : "0b",
    "pri.fielddata.memory\_size" : "0b",
    "pri.fielddata.memory\_size" : "0b",
    "fielddata.evictions" : "0",
    "pri.fielddata.evictions" : "0",
    "pri.fielddata.evictions" : "0",
    "query\_cache.memory\_size" : "0b",
    "pri.query\_cache.memory\_size" : "0b",
    "pri.query\_cache.memory\_size" : "0b",
    "query\_cache.evictions" : "0",
    "pri.query\_cache.evictions" : "0",
    "pri.query\_cache.evictions" : "0",
    "request\_cache.memory\_size" : "3.4kb",
    "pri.request\_cache.memory\_size" : "3.4kb",
    "pri.request\_cache.memory\_size" : "3.4kb",
    "request\_cache.evictions" : "0",
    "pri.request\_cache.evictions" : "0",
    "pri.request\_cache.evictions" : "0",
    "request\_cache.hit\_count" : "0",
    "pri.request\_cache.hit\_count" : "0",
    "pri.request\_cache.hit\_count" : "0",
    "request\_cache.miss\_count" : "5",
    "pri.request\_cache.miss\_count" : "5",
    "pri.request\_cache.miss\_count" : "5",
    "flush.total" : "5",
    "pri.flush.total" : "5",
    "pri.flush.total" : "5",
    "flush.total\_time" : "0s",
    "pri.flush.total\_time" : "0s",
    "pri.flush.total\_time" : "0s",
    "get.current" : "0",
    "pri.get.current" : "0",
    "pri.get.current" : "0",
    "get.time" : "0s",
    "pri.get.time" : "0s",
    "pri.get.time" : "0s",
    "get.total" : "0",
    "pri.get.total" : "0",
    "pri.get.total" : "0",
    "get.exists\_time" : "0s",
    "pri.get.exists\_time" : "0s",
    "pri.get.exists\_time" : "0s",
    "get.exists\_total" : "0",
    "pri.get.exists\_total" : "0",
    "pri.get.exists\_total" : "0",
    "get.missing\_time" : "0s",
    "pri.get.missing\_time" : "0s",
    "pri.get.missing\_time" : "0s",
    "get.missing\_total" : "0",
    "pri.get.missing\_total" : "0",
    "pri.get.missing\_total" : "0",
    "indexing.delete\_current" : "0",
    "pri.indexing.delete\_current" : "0",
    "pri.indexing.delete\_current" : "0",
    "indexing.delete\_time" : "0s",
    "pri.indexing.delete\_time" : "0s",
    "pri.indexing.delete\_time" : "0s",
    "indexing.delete\_total" : "0",
    "pri.indexing.delete\_total" : "0",
    "pri.indexing.delete\_total" : "0",
    "indexing.index\_current" : "0",
    "pri.indexing.index\_current" : "0",
    "pri.indexing.index\_current" : "0",
    "indexing.index\_time" : "0s",
    "pri.indexing.index\_time" : "0s",
    "pri.indexing.index\_time" : "0s",
    "indexing.index\_total" : "0",
    "pri.indexing.index\_total" : "0",
    "pri.indexing.index\_total" : "0",
    "indexing.index\_failed" : "0",
    "pri.indexing.index\_failed" : "0",
    "pri.indexing.index\_failed" : "0",
    "merges.current" : "0",
    "pri.merges.current" : "0",
    "pri.merges.current" : "0",
    "merges.current\_docs" : "0",
    "pri.merges.current\_docs" : "0",
    "pri.merges.current\_docs" : "0",
    "merges.current\_size" : "0b",
    "pri.merges.current\_size" : "0b",
    "pri.merges.current\_size" : "0b",
    "merges.total" : "0",
    "pri.merges.total" : "0",
    "pri.merges.total" : "0",
    "merges.total\_docs" : "0",
    "pri.merges.total\_docs" : "0",
    "pri.merges.total\_docs" : "0",
    "merges.total\_size" : "0b",
    "pri.merges.total\_size" : "0b",
    "pri.merges.total\_size" : "0b",
    "merges.total\_time" : "0s",
    "pri.merges.total\_time" : "0s",
    "pri.merges.total\_time" : "0s",
    "refresh.total" : "15",
    "pri.refresh.total" : "15",
    "pri.refresh.total" : "15",
    "refresh.time" : "0s",
    "pri.refresh.time" : "0s",
    "pri.refresh.time" : "0s",
    "refresh.listeners" : "0",
    "pri.refresh.listeners" : "0",
    "pri.refresh.listeners" : "0",
    "search.fetch\_current" : "0",
    "pri.search.fetch\_current" : "0",
    "pri.search.fetch\_current" : "0",
    "search.fetch\_time" : "0s",
    "pri.search.fetch\_time" : "0s",
    "pri.search.fetch\_time" : "0s",
    "search.fetch\_total" : "0",
    "pri.search.fetch\_total" : "0",
    "pri.search.fetch\_total" : "0",
    "search.open\_contexts" : "0",
    "pri.search.open\_contexts" : "0",
    "pri.search.open\_contexts" : "0",
    "search.query\_current" : "0",
    "pri.search.query\_current" : "0",
    "pri.search.query\_current" : "0",
    "search.query\_time" : "0s",
    "pri.search.query\_time" : "0s",
    "pri.search.query\_time" : "0s",
    "search.query\_total" : "5",
    "pri.search.query\_total" : "5",
    "pri.search.query\_total" : "5",
    "search.scroll\_current" : "0",
    "pri.search.scroll\_current" : "0",
    "pri.search.scroll\_current" : "0",
    "search.scroll\_time" : "0s",
    "pri.search.scroll\_time" : "0s",
    "pri.search.scroll\_time" : "0s",
    "search.scroll\_total" : "0",
    "pri.search.scroll\_total" : "0",
    "pri.search.scroll\_total" : "0",
    "segments.count" : "47",
    "pri.segments.count" : "47",
    "pri.segments.count" : "47",
    "segments.memory" : "1.2mb",
    "pri.segments.memory" : "1.2mb",
    "pri.segments.memory" : "1.2mb",
    "segments.index\_writer\_memory" : "0b",
    "pri.segments.index\_writer\_memory" : "0b",
    "pri.segments.index\_writer\_memory" : "0b",
    "segments.version\_map\_memory" : "0b",
    "pri.segments.version\_map\_memory" : "0b",
    "pri.segments.version\_map\_memory" : "0b",
    "segments.fixed\_bitset\_memory" : "0b",
    "pri.segments.fixed\_bitset\_memory" : "0b",
    "pri.segments.fixed\_bitset\_memory" : "0b",
    "warmer.current" : "0",
    "pri.warmer.current" : "0",
    "pri.warmer.current" : "0",
    "warmer.total" : "5",
    "pri.warmer.total" : "5",
    "pri.warmer.total" : "5",
    "warmer.total\_time" : "0s",
    "pri.warmer.total\_time" : "0s",
    "pri.warmer.total\_time" : "0s",
    "suggest.current" : "0",
    "pri.suggest.current" : "0",
    "pri.suggest.current" : "0",
    "suggest.time" : "0s",
    "pri.suggest.time" : "0s",
    "pri.suggest.time" : "0s",
    "suggest.total" : "0",
    "pri.suggest.total" : "0",
    "pri.suggest.total" : "0",
    "memory.total" : "1.2mb",
    "pri.memory.total" : "1.2mb",
    "pri.memory.total" : "1.2mb"
  }
] 


Shards(分片)

详细视图

提供什么节点包含哪些分片的详细视图。它将告诉您它是主分片还是副本、文档的数量、它在磁盘上占用的字节数以及它所在的节点。

GET _cat/shards?v
GET _cat/shards/twitt*

未分配分片

GET _cat/shards?h=index,shard,prirep,state,unassigned.reason

Segments(段)

底层信息

提供有关索引分片中的段的底层信息。

GET /_cat/segments?v

响应格式

  {
    "index" : "es-7.7.0-2020.10.23.17.40",
    "shard" : "0",
    "prirep" : "p",   //此段属于主分片还是复制分片。
    "ip" : "192.168.0.1",
    "segment" : "_1g",   //从生成的段派生出的段名。该名称在内部用于在此段所属的切分目录中生成文件名。
    "generation" : "52",  //生成号随着写入的每个段而增加。段的名称派生自这个代号。
    "docs.count" : "48536",   //存储在此段中的未删除文档的数量。请注意,这些都是Lucene文档,因此计数将包括隐藏文档(例如来自嵌套类型的文档)。
    "docs.deleted" : "0",  //存储在此段中的已删除文档的数量。如果这个数大于0,那么当这个段被合并时,空间将被回收。
    "size" : "16.3mb",    //此段所使用的磁盘空间。
    "size.memory" : "43287",  //段将一些数据存储到内存中,以便有效地进行搜索。此列显示所使用的内存字节数。
    "committed" : "true", //该段是否已在磁盘上同步。提交的段可以在重启的时候存活。无需担心false,未提交段的数据也存储在事务日志中,以便Elasticsearch能够在下一次开始时重播更改。
    "searchable" : "true",  //如果片段是可搜索的,则为true。值为false很可能意味着该段已被写入磁盘,但此后未发生刷新以使其可搜索。
    "version" : "7.5.0",  //用于编写此段的Lucene版本。
    "compound" : "false"    //该段是否存储在复合文件中。当为true时,这意味着Lucene将该段中的所有文件合并为一个文件,以保存文件描述符。
    }

详细信息

提供关于分片和索引状态的更多信息,可能还有优化信息、删除时“浪费”的数据,等等。

GET /test/_segments
GET /test1,test2/_segments
GET /_segments

响应解析

{
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "indices" : {
    "es-7.7.0-2020.10.23.09.13" : {
      "shards" : {
        "0" : [
          {
            "routing" : {
              "state" : "STARTED",
              "primary" : true,
              "node" : "B-M3lfhbQfS88kIq64pECQ"
            },
            "num_committed_segments" : 3,
            "num_search_segments" : 3,
            "segments" : {
              "_0" : {    //JSON文档的键是段的名称。此名称用于生成文件名:切分目录中以此段名称开头的所有文件都属于此段。
                "generation" : 0,   //当需要写入新段时,生成号基本上是递增的。段名派生自这个代号。
                "num_docs" : 745,   //存储在此段中的未删除文档的数量。
                "deleted_docs" : 0,   //存储在此段中的已删除文档的数量。如果这个数大于0,那么当这个段被合并时,空间将被回收。
                "size_in_bytes" : 381443,   //此段使用的磁盘空间量,以字节为单位。
                "memory_in_bytes" : 6500,    //段需要存储一些数据到内存中,以便有效地搜索。这个数字返回用于此目的的字节数。值为-1表示Elasticsearch不能计算这个数字。
                "committed" : true,     //该段是否已在磁盘上同步。提交的段可以在硬重新引导中存活。无需担心false,未提交段的数据也存储在事务日志中,以便Elasticsearch能够在下一次开始时重播更改。
                "search" : true,   //该片段是否可搜索。值为false很可能意味着该段已被写入磁盘,但此后未发生刷新以使其可搜索。
                "version" : "7.5.0",  //用于编写此段的Lucene版本。
                "compound" : true,    //该段是否存储在复合文件中。当为true时,这意味着Lucene将该段中的所有文件合并为一个文件,以保存文件描述符。
                "attributes" : {   //包含有关是否启用了高压缩的信息
                  "Lucene50StoredFieldsFormat.mode" : "BEST_SPEED"
                }
              },
              "_1" : {
                "generation" : 1,
                "num_docs" : 1253,
                "deleted_docs" : 0,
                "size_in_bytes" : 593668,
                "memory_in_bytes" : 8111,
                "committed" : true,
                "search" : true,
                "version" : "7.5.0",
                "compound" : true,
                "attributes" : {
                  "Lucene50StoredFieldsFormat.mode" : "BEST_SPEED"
                }
              },
              "_2" : {
                "generation" : 2,
                "num_docs" : 405,
                "deleted_docs" : 0,
                "size_in_bytes" : 209748,
                "memory_in_bytes" : 6518,
                "committed" : true,
                "search" : true,
                "version" : "7.5.0",
                "compound" : true,
                "attributes" : {
                  "Lucene50StoredFieldsFormat.mode" : "BEST_SPEED"
                }
              }
            }
          }
        ],
        。。。

调试信息

若要添加可用于调试的其他信息,请使用verbose标志。

GET /test/_segments?verbose=true

Cluster Settings(集群配置)

获取配置

GET /_cluster/settings
GET /_cluster/settings?include_defaults=true

持久配置

现在能在网上找到很多很多的学习资源,有免费的也有收费的,当我拿到1套比较全的学习资源之前,我并没着急去看第1节,我而是去审视这套资源是否值得学习,有时候也会去问一些学长的意见,如果可以之后,我会对这套学习资源做1个学习计划,我的学习计划主要包括规划图和学习进度表。

分享给大家这份我薅到的免费视频资料,质量还不错,大家可以跟着学习

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里无偿获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 7
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值