毕业没多久,由于工作原因,被老大安排学习elasticsearch并用于日志检索以提高线上日志的排查效率。那时候对于很多东西都没有概念,对elasticsearch的理解也不够全面,所以搞出来的东西也是七七八八,后面随着线上环境的使用,以及工作上面和它不断的打交道,开始对它有了一个全面的了解,这篇我们先来讲一下cat API的使用。
文章目录
- 一、cat是什么?
- 二、命令详细说明
- 1.cat aliases API
- 2.cat allocation API
- 3.cat count API
- 4.cat fielddata API
- 5.cat health API
- 6.cat indices API
- 7.cat master API
- 8.cat nodeattrs API
- 9.cat nodes API
- 10.cat pending task API
- 11.cat plugins API
- 12.cat recovery API
- 13.cat task management API
- 14.cat thread pool API
- 15.cat shards API
- 16.cat segments API
- 17.cat templates
一、cat是什么?
没错,cat就是猫,你不信看看帮助命令里面,第一行就是一个猫脸。
哈,其实这个命令是用来看一些elasticsearch运行状态的,我把它理解为catch
。
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates
二、命令详细说明
1.cat aliases API
查询索引别名的详细信息。
请求
GET /_cat/aliases/<alias>
GET /_cat/aliases
参数说明
<alias> :可选值,主要是填index别名,多个索引别名以逗号分隔。
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/aliases?v
alias index filter routing.index routing.search
.security .security-6 - - -
2.cat allocation API
查看数据节点上面的磁盘的快照信息。
请求
GET /_cat/allocation/<node_id>
GET /_cat/allocation
参数说明
<node_id>:可选参数,主要是填入id值或者elasticsearch.yml中配置的node.name
的值。
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/allocation/node-15?v
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node
6 20.8kb 8.2gb 3.7gb 11.9gb 68 192.168.133.15 192.168.133.15 node-15
其中磁盘使用使用情况是当前数据节点上面的的磁盘状态。
3.cat count API
统计所有索引的文档数目,或者指定索引的文档数目。
请求
GET /_cat/count/<index>
GET /_cat/count
参数说明
<index>:可选参数,填入索引名称精确到查询某个索引的文档数量。
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/count/.security-6?v
epoch timestamp count
1576240586 12:36:26 6
4.cat fielddata API
返回集群中每个数据节点用于fielddata的堆内存数量。
读者这里可能对fielddata没什么概念。没关系,你只需要记住这是在内存中排序时需要用到的东西就可以了。
请求
GET /_cat/fielddata/<field>
GET /_cat/fielddata
参数说明
<field>:可选参数,填入字段名称
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/fielddata/body,soul?v
id host ip node field size
Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in body 544b
Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in soul 480b
5.cat health API
查看集群健康的API。
请求
GET /_cat/health
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/health?v
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1576242040 13:00:40 powercloud_log green 2 2 12 6 0 0 0 0 - 100.0%
6.cat indices API
返回集群中索引的高级信息。
请求
GET /_cat/indices/<index>
GET /_cat/indices
参数说明
<index>:可选参数,填入索引名称
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/indices/.security-6?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .security-6 3Kmx1dJNTIuvGFa4OSufvA 1 1 6 0 39.1kb 19.5kb
7.cat master API
返回集群中节点角色为master的节点信息。包含ID,IP和名称。
请求
GET /_cat/master
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/master?v
id host ip node
PesaAql7RjeYxEe3VLc1dw 192.168.133.14 192.168.133.14 node-14
8.cat nodeattrs API
自定义节点属性。
请求
GET /_cat/nodeattrs
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/nodeattrs?v
node host ip attr value
node-15 192.168.133.15 192.168.133.15 ml.machine_memory 1019797504
node-15 192.168.133.15 192.168.133.15 ml.max_open_jobs 20
node-15 192.168.133.15 192.168.133.15 xpack.installed true
node-15 192.168.133.15 192.168.133.15 ml.enabled true
node-14 192.168.133.14 192.168.133.14 ml.machine_memory 1019797504
node-14 192.168.133.14 192.168.133.14 ml.max_open_jobs 20
node-14 192.168.133.14 192.168.133.14 xpack.installed true
node-14 192.168.133.14 192.168.133.14 ml.enabled true
9.cat nodes API
返回集群中节点的信息。
请求
GET /_cat/nodes
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.133.15 56 91 1 0.00 0.01 0.05 di - node-15
192.168.133.14 72 91 1 0.00 0.01 0.05 mdi * node-14
这里返回的是默认的一些信息,如果要查看其他信息,可以用h
参数。
参考官方给出的表:
h
(Optional, string) Comma-separated list of column names to display.
If you do not specify which columns to include, the API returns the default columns in the order listed below. If you explicitly specify one or more columns, it only returns the specified columns.
Valid columns are:
ip, i
(Default) IP address, such as 127.0.1.1.
heap.percent, hp, heapPercent
(Default) Maximum configured heap, such as 7.
ram.percent, rp, ramPercent
(Default) Used total memory percentage, such as 47.
file_desc.percent, fdp, fileDescriptorPercent
(Default) Used file descriptors percentage, such as 1.
node.role, r, role, nodeRole
(Default) Roles of the node. Returned values include d (data node), i (ingest node), m (master-eligible node), l (machine learning node), v (voting-only node), and - (coordinating node only).
For example, dim indicates a master-eligible data and ingest node. See Node.
master, m
(Default) Indicates whether the node is the elected master node. Returned values include * (elected master) and - (not elected master).
name, n
(Default) Node name, such as I8hydUG.
id, nodeId
ID of the node, such as k0zy.
pid, p
Process ID, such as 13061.
port, po
Bound transport port, such as 9300.
http_address, http
Bound http address, such as 127.0.0.1:9200.
version, v
Elasticsearch version, such as 7.5.0.
build, b
Elasticsearch build hash, such as 5c03844.
jdk, j
Java version, such as 1.8.0.
disk.total, dt, diskTotal
Total disk space, such as 458.3gb.
disk.used, du, diskUsed
Used disk space, such as 259.8gb.
disk.avail, d, disk, diskAvail
Available disk space, such as 198.4gb.
disk.used_percent, dup, diskUsedPercent
Used disk space percentage, such as 198.4gb.
heap.current, hc, heapCurrent
Used heap, such as 311.2mb.
ram.current,rc, ramCurrent
Used total memory, such as 513.4mb.
ram.max, rm, ramMax
Total memory, such as 2.9gb.
file_desc.current, fdc, fileDescriptorCurrent
Used file descriptors, such as 123.
file_desc.max, fdm, fileDescriptorMax
Maximum number of file descriptors, such as 1024.
cpu
Recent system CPU usage as percent, such as 12.
load_1m, l
Most recent load average, such as 0.22.
load_5m, l
Load average for the last five minutes, such as 0.78.
load_15m, l
Load average for the last fifteen minutes, such as 1.24.
uptime, u
Node uptime, such as 17.3m.
completion.size, cs, completionSize
Size of completion, such as 0b.
fielddata.memory_size, fm, fielddataMemory
Used fielddata cache memory, such as 0b.
fielddata.evictions, fe, fielddataEvictions
Fielddata cache evictions, such as 0.
query_cache.memory_size, qcm, queryCacheMemory
Used query cache memory, such as 0b.
query_cache.evictions, qce, queryCacheEvictions
Query cache evictions, such as 0.
request_cache.memory_size, rcm, requestCacheMemory
Used request cache memory, such as 0b.
request_cache.evictions, rce, requestCacheEvictions
Request cache evictions, such as 0.
request_cache.hit_count, rchc, requestCacheHitCount
Request cache hit count, such as 0.
request_cache.miss_count, rcmc, requestCacheMissCount
Request cache miss count, such as 0.
flush.total, ft, flushTotal
Number of flushes, such as 1.
flush.total_time, ftt, flushTotalTime
Time spent in flush, such as 1.
get.current, gc, getCurrent
Number of current get operations, such as 0.
get.time, gti, getTime
Time spent in get, such as 14ms.
get.total, gto, getTotal
Number of get operations, such as 2.
get.exists_time, geti, getExistsTime
Time spent in successful gets, such as 14ms.
get.exists_total, geto, getExistsTotal
Number of successful get operations, such as 2.
get.missing_time, gmti, getMissingTime
Time spent in failed gets, such as 0s.
get.missing_total, gmto, getMissingTotal
Number of failed get operations, such as 1.
indexing.delete_current, idc, indexingDeleteCurrent
Number of current deletion operations, such as 0.
indexing.delete_time, idti, indexingDeleteTime
Time spent in deletions, such as 2ms.
indexing.delete_total, idto, indexingDeleteTotal
Number of deletion operations, such as 2.
indexing.index_current, iic, indexingIndexCurrent
Number of current indexing operations, such as 0.
indexing.index_time, iiti, indexingIndexTime
Time spent in indexing, such as 134ms.
indexing.index_total, iito, indexingIndexTotal
Number of indexing operations, such as 1.
indexing.index_failed, iif, indexingIndexFailed
Number of failed indexing operations, such as 0.
merges.current, mc, mergesCurrent
Number of current merge operations, such as 0.
merges.current_docs, mcd, mergesCurrentDocs
Number of current merging documents, such as 0.
merges.current_size, mcs, mergesCurrentSize
Size of current merges, such as 0b.
merges.total, mt, mergesTotal
Number of completed merge operations, such as 0.
merges.total_docs, mtd, mergesTotalDocs
Number of merged documents, such as 0.
merges.total_size, mts, mergesTotalSize
Size of current merges, such as 0b.
merges.total_time, mtt, mergesTotalTime
Time spent merging documents, such as 0s.
refresh.total, rto, refreshTotal
Number of refreshes, such as 16.
refresh.time, rti, refreshTime
Time spent in refreshes, such as 91ms.
script.compilations, scrcc, scriptCompilations
Total script compilations, such as 17.
script.cache_evictions, scrce, scriptCacheEvictions
Total compiled scripts evicted from cache, such as 6.
search.fetch_current, sfc, searchFetchCurrent
Current fetch phase operations, such as 0.
search.fetch_time, sfti, searchFetchTime
Time spent in fetch phase, such as 37ms.
search.fetch_total, sfto, searchFetchTotal
Number of fetch operations, such as 7.
search.open_contexts, so, searchOpenContexts
Open search contexts, such as 0.
search.query_current, sqc, searchQueryCurrent
Current query phase operations, such as 0.
search.query_time, sqti, searchQueryTime
Time spent in query phase, such as 43ms.
search.query_total, sqto, searchQueryTotal
Number of query operations, such as 9.
search.scroll_current, scc, searchScrollCurrent
Open scroll contexts, such as 2.
search.scroll_time, scti, searchScrollTime
Time scroll contexts held open, such as 2m.
search.scroll_total, scto, searchScrollTotal
Completed scroll contexts, such as 1.
segments.count, sc, segmentsCount
Number of segments, such as 4.
segments.memory, sm, segmentsMemory
Memory used by segments, such as 1.4kb.
segments.index_writer_memory, siwm, segmentsIndexWriterMemory
Memory used by index writer, such as 18mb.
segments.version_map_memory, svmm, segmentsVersionMapMemory
Memory used by version map, such as 1.0kb.
segments.fixed_bitset_memory, sfbm, fixedBitsetMemory
Memory used by fixed bit sets for nested object field types and type filters for types referred in join fields, such as 1.0kb.
suggest.current, suc, suggestCurrent
Number of current suggest operations, such as 0.
suggest.time, suti, suggestTime
Time spent in suggest, such as 0.
suggest.total, suto, suggestTotal
Number of suggest operations, such as 0.
10.cat pending task API
返回尚未执行的集群级更改,类似于挂起的集群任务API。
请求
GET /_cat/pending_tasks
举例
curl -XGET http://127.0.0.1:9200/_cat/pending_tasks?v
insertOrder timeInQueue priority source
1685 855ms HIGH update-mapping [foo][t]
1686 843ms HIGH update-mapping [foo][t]
1693 753ms HIGH refresh-mapping [foo][[t]]
1688 816ms HIGH update-mapping [foo][t]
1689 802ms HIGH update-mapping [foo][t]
1690 787ms HIGH update-mapping [foo][t]
1691 773ms HIGH update-mapping [foo][t]
11.cat plugins API
返回集群中安装的插件信息。
请求
GET /_cat/plugins
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/plugins?v\&s=component\&h=name,component,version,description
name component version description
node-15 analysis-ik 6.6.2 IK Analyzer for Elasticsearch
node-14 analysis-ik 6.6.2 IK Analyzer for Elasticsearch
node-15 analysis-pinyin 6.6.2 Pinyin Analysis for Elasticsearch
node-14 analysis-pinyin 6.6.2 Pinyin Analysis for Elasticsearch
12.cat recovery API
返回关于正在进行和完成的碎片恢复的信息,类似于index recovery API。
cat recovery API返回关于碎片恢复的信息,包括正在进行的和已完成的。它是JSON索引恢复API的一个更紧凑的视图。碎片恢复是从主碎片同步复制碎片的过程。完成后,副本碎片可以进行搜索
请求
GET /_cat/recovery/<index>
GET /_cat/recovery
参数说明
<index>:可选参数,填入索引名称
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/recovery?v
index shard time type stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
young 0 453ms empty_store done n/a n/a 192.168.133.14 node-14 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
young 0 728ms peer done 192.168.133.14 node-14 192.168.133.15 node-15 n/a n/a 1 1 100.0% 1 230 230 100.0% 230 0 0 100.0%
young 1 451ms peer done 192.168.133.15 node-15 192.168.133.14 node-14 n/a n/a 1 1 100.0% 1 230 230 100.0% 230 0 0 100.0%
young 1 336ms empty_store done n/a n/a 192.168.133.15 node-15 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
young 2 580ms empty_store done n/a n/a 192.168.133.14 node-14 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
young 2 670ms peer done 192.168.133.14 node-14 192.168.133.15 node-15 n/a n/a 1 1 100.0% 1 230 230 100.0% 230 0 0 100.0%
young 3 366ms peer done 192.168.133.15 node-15 192.168.133.14 node-14 n/a n/a 1 1 100.0% 1 230 230 100.0% 230 0 0 100.0%
young 3 286ms empty_store done n/a n/a 192.168.133.15 node-15 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
young 4 500ms empty_store done n/a n/a 192.168.133.14 node-14 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
young 4 971ms peer done 192.168.133.14 node-14 192.168.133.15 node-15 n/a n/a 1 1 100.0% 1 230 230 100.0% 230 0 0 100.0%
.security-6 0 1.2s existing_store done n/a n/a 192.168.133.14 node-14 n/a n/a 0 0 100.0% 19 0 0 100.0% 20045 0 0 100.0%
.security-6 0 1.3s peer done 192.168.133.14 node-14 192.168.133.15 node-15 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0%
13.cat task management API
返回关于当前在集群中执行的任务的信息。
请求
GET /_cat/tasks
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/tasks?v
action task_id parent_task_id type start_time timestamp running_time ip node
cluster:monitor/tasks/lists CtcpSn2OQeGuGNbsSaXJwQ:7955 - transport 1576244653037 13:44:13 17.1ms 192.168.133.15 node-15
cluster:monitor/tasks/lists[n] CtcpSn2OQeGuGNbsSaXJwQ:7956 CtcpSn2OQeGuGNbsSaXJwQ:7955 direct 1576244653044 13:44:13 10.2ms 192.168.133.15 node-15
cluster:monitor/tasks/lists[n] PesaAql7RjeYxEe3VLc1dw:8431 CtcpSn2OQeGuGNbsSaXJwQ:7955 netty 1576244653051 13:44:13 8.4ms 192.168.133.14 node-14
14.cat thread pool API
返回集群中每个节点的线程池统计信息。返回的信息包括所有内置线程池和自定义线程池。
请求
GET /_cat/thread_pool/<thread_pool>
GET /_cat/thread_pool
参数说明
<thread_pool>:用逗号分隔的线程池名称列表,用于限制请求,可以用通配符表达式。
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/thread_pool?v
node_name name active queue rejected
node-15 analyze 0 0 0
node-15 ccr 0 0 0
node-15 fetch_shard_started 0 0 0
node-15 fetch_shard_store 0 0 0
node-15 flush 0 0 0
node-15 force_merge 0 0 0
node-15 generic 0 0 0
node-15 get 0 0 0
node-15 index 0 0 0
node-15 listener 0 0 0
node-15 management 1 0 0
node-15 ml_autodetect 0 0 0
node-15 ml_datafeed 0 0 0
node-15 ml_utility 0 0 0
node-15 refresh 0 0 0
node-15 rollup_indexing 0 0 0
node-15 search 0 0 0
node-15 search_throttled 0 0 0
node-15 snapshot 0 0 0
node-15 warmer 0 0 0
node-15 watcher 0 0 0
node-15 write 0 0 0
node-14 analyze 0 0 0
node-14 ccr 0 0 0
node-14 fetch_shard_started 0 0 0
node-14 fetch_shard_store 0 0 0
node-14 flush 0 0 0
node-14 force_merge 0 0 0
node-14 generic 0 0 0
node-14 get 0 0 0
node-14 index 0 0 0
node-14 listener 0 0 0
node-14 management 1 0 0
node-14 ml_autodetect 0 0 0
node-14 ml_datafeed 0 0 0
node-14 ml_utility 0 0 0
node-14 refresh 0 0 0
node-14 rollup_indexing 0 0 0
node-14 search 0 0 0
node-14 search_throttled 0 0 0
node-14 snapshot 0 0 0
node-14 warmer 0 0 0
node-14 watcher 0 0 0
node-14 write 0 0 0
15.cat shards API
shards命令是有关哪些节点包含哪些分片的详细视图。 给出它是主数据库还是副本数据库,文档数量,它在磁盘上占用的字节数以及它所在的节点。
请求
GET /_cat/shards/<index>
GET /_cat/shards
参数说明
<index>:用逗号分隔的索引名称。
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/shards/young?v
index shard prirep state docs store ip node
young 1 r STARTED 0 261b 192.168.133.14 node-14
young 1 p STARTED 0 261b 192.168.133.15 node-15
young 3 r STARTED 0 261b 192.168.133.14 node-14
young 3 p STARTED 0 261b 192.168.133.15 node-15
young 2 p STARTED 0 261b 192.168.133.14 node-14
young 2 r STARTED 0 261b 192.168.133.15 node-15
young 4 p STARTED 0 261b 192.168.133.14 node-14
young 4 r STARTED 0 261b 192.168.133.15 node-15
young 0 p STARTED 0 261b 192.168.133.14 node-14
young 0 r STARTED 0 261b 192.168.133.15 node-15
16.cat segments API
在索引碎片中返回关于Lucene段的低级信息.
请求
GET /_cat/segments/<index>
GET /_cat/segments
参数说明
<index>:用逗号分隔的索引名称。
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/segments?v
index shard prirep ip segment generation docs.count docs.deleted size size.memory committed searchable version compound
.security-6 0 p 192.168.133.14 _0 0 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 p 192.168.133.14 _1 1 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 p 192.168.133.14 _2 2 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 p 192.168.133.14 _3 3 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 p 192.168.133.14 _4 4 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 p 192.168.133.14 _5 5 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 r 192.168.133.15 _0 0 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 r 192.168.133.15 _1 1 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 r 192.168.133.15 _2 2 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 r 192.168.133.15 _3 3 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 r 192.168.133.15 _4 4 1 0 3.1kb 1120 true true 7.6.0 true
.security-6 0 r 192.168.133.15 _5 5 1 0 3.1kb 1120 true true 7.6.0 true
17.cat templates
返回关于集群中的索引模板的信息。可以使用索引模板在创建时将索引设置和字段映射应用到新索引。
请求
GET /_cat/templates/<template_name>
GET /_cat/templates
参数说明
<template_name>:模板名称
举例
[root@node15 es]# curl -XGET http://127.0.0.1:9200/_cat/templates?v
name index_patterns order version
.ml-config [.ml-config] 0 6060299
.monitoring-kibana [.monitoring-kibana-6-*] 0 6050399
.ml-notifications [.ml-notifications] 0 6060299
template_1 [te*, bar*] 0
.triggered_watches [.triggered_watches*] 2147483647
security_audit_log [.security_audit_log*] 1000
.monitoring-beats [.monitoring-beats-6-*] 0 6050399
.ml-anomalies- [.ml-anomalies-*] 0 6060299
.ml-state [.ml-state] 0 6060299
logstash-index-template [.logstash] 0
.ml-meta [.ml-meta] 0 6060299
.monitoring-alerts [.monitoring-alerts-6] 0 6050399
.watch-history-9 [.watcher-history-9*] 2147483647
.monitoring-logstash [.monitoring-logstash-6-*] 0 6050399
.watches [.watches*] 2147483647
.monitoring-es [.monitoring-es-6-*] 0 6050399
security-index-template [.security-*] 1000
这里的模板template_1
是我新建的:
[root@node15 es]# curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/_template/template_1 -d'
> {
> "index_patterns": ["te*", "bar*"],
> "settings": {
> "number_of_shards": 1
> },
> "mappings": {
> "_doc": {
> "_source": {
> "enabled": false
> },
> "properties": {
> "host_name": {
> "type": "keyword"
> },
> "created_at": {
> "type": "date",
> "format": "EEE MMM dd HH:mm:ss Z yyyy"
> }
> }
> }
> }
> }'
{"acknowledged":true}
模板的作用是遇到匹配的索引被创建时,会自动帮我建一个格式化好的索引:
[root@node15 es]# curl -XPUT http://127.0.0.1:9200/tea
{"acknowledged":true,"shards_acknowledged":true,"index":"tea"}[root@node15 es]#
[root@node15 es]# curl -XGET http://127.0.0.1:9200/tea/_mapping
{"tea":{"mappings":{"_doc":{"_source":{"enabled":false},"properties":{"created_at":{"type":"date","format":"EEE MMM dd HH:mm:ss Z yyyy"},"host_name":{"type":"keyword"}}}}}}
以上是对cat API的总结。坐在这里一边测一边码字,写了两个小时,如果觉得还看得过去,可以收藏关注下,谢谢。