ElasticSearch Cat API
-
Cat API
通常,各种Elasticsearch API的结果以JSON格式显示。但是,JSON并非总是易于阅读。因此,Elasticsearch中提供了cat APIs功能,有助于使结果更易于阅读和理解。cat API中使用了各种参数,这些参数有不同的用途,例如-术语 V 使输出变得更详细。让我们在本章中更详细地了解cat API。 -
详细
详细的输出可以很好地显示cat命令的结果。在下面给出的示例中,我们获得了集群中存在的各种索引的详细信息。GET /_cat/indices?v
运行上面的代码后,我们得到如下所示的响应:health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .apm-custom-link S_sVCZ5mTjKJ-JzwzoDn-A 1 0 0 0 208b 208b yellow open test RU7mX6UAT_iC35XCoVpq1Q 1 1 4 0 10.7kb 10.7kb yellow open school laIr7lx_RmKmdMwsTaxauA 1 1 3 1 29.9kb 29.9kb green open kibana_sample_data_ecommerce bOto2NggThKCCVVpvoeUUQ 1 0 4675 0 4.2mb 4.2mb green open .kibana_task_manager_1 5KiitZgFSH-6b9A5p-LM0g 1 0 5 1 56kb 56kb green open .apm-agent-configuration 72wxunbiRri88LPZ36GmUA 1 0 0 0 208b 208b yellow open colleges mQsQCcTJT0qcL8iFMADH2w 3 2 0 0 624b 624b green open .async-search zA6iF_hdTdex9xflznhaOg 1 0 0 0 3.7kb 3.7kb green open .kibana-event-log-7.10.2-000001 qCCJRY-5S8KyXsxaSaPUQA 1 0 1 0 5.6kb 5.6kb green open .kibana_1 -8g-FOSFQ3iQqylXRfg7mw 1 0 56 0 3mb 3mb
-
标头(headers)
h参数(也称为标头)仅用于显示命令中提到的那些列。GET /_cat/nodes?h=ip,port
运行上面的代码后,我们得到如下所示的响应:127.0.0.1 9300
-
排序
sort命令接受查询字符串,该字符串可以按查询中的指定列对表进行排序。默认排序是升序的,但是可以通过在列中添加:desc来更改。以下示例给出了按字段索引模式的降序排列的模板的结果。GET _cat/templates?v&s=order:desc,index_patterns
运行上面的代码后,我们得到如下所示的响应:name index_patterns order version composed_of .slm-history [.slm-history-3*] 2147483647 3 [] .triggered_watches [.triggered_watches*] 2147483647 12 [] .watch-history-12 [.watcher-history-12*] 2147483647 12 [] .watches [.watches*] 2147483647 12 [] ilm-history [ilm-history-3*] 2147483647 3 [] logs [logs-*-*] 100 0 [logs-mappings, logs-settings] metrics [metrics-*-*] 100 0 [metrics-mappings, metrics-settings] synthetics [synthetics-*-*] 100 0 [synthetics-mappings, synthetics-settings] .kibana-event-log-7.10.2-template [.kibana-event-log-7.10.2-*] 0 .logstash-management [.logstash] 0 .management-beats [.management-beats] 0 70000 .ml-anomalies- [.ml-anomalies-*] 0 7100299 .ml-config [.ml-config] 0 7100299 .ml-inference-000003 [.ml-inference-000003] 0 7100299 .ml-meta [.ml-meta] 0 7100299 .ml-notifications-000001 [.ml-notifications-000001] 0 7100299 .ml-state [.ml-state*] 0 7100299 .ml-stats [.ml-stats-*] 0 7100299 .monitoring-alerts-7 [.monitoring-alerts-7] 0 7000199 .monitoring-beats [.monitoring-beats-7-*] 0 7000199 .monitoring-es [.monitoring-es-7-*] 0 7000199 .monitoring-kibana [.monitoring-kibana-7-*] 0 7000199 .monitoring-logstash [.monitoring-logstash-7-*] 0 7000199 .transform-internal-005 [.transform-internal-005] 0 7100299 .transform-notifications-000002 [.transform-notifications-*] 0 7100299
-
计数
count参数提供整个集群中文档总数的计数。GET /_cat/count?v
运行上面的代码后,我们得到如下所示的响应:epoch timestamp count 1557633536 03:58:56 17809