json ElasticSearch 获取索引名称和存储大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29762111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ElasticSearch Get Index Names and Store Size
提问by Gregg
I am attempting to capture a list of all the indexes and their sizes in a way that I could capture the information using Angular's $http service and then iterate through the information using the ng-repeat preferably with something like:
我试图以一种可以使用 Angular 的 $http 服务捕获信息的方式捕获所有索引及其大小的列表,然后使用 ng-repeat 最好使用以下内容迭代信息:
<ul ng-repeat="elsindex in elsIndexHttpResponse">
<li>{{elsindex.name}}:{{elsindex.size}}</li>
</ul>
<ul ng-repeat="elsindex in elsIndexHttpResponse">
<li>{{elsindex.name}}:{{elsindex.size}}</li>
</ul>
The closest thing I have found is this: http://localhost:9200/_cat/indices?h=index,store.size
我发现的最接近的是: http://localhost:9200/_cat/indices?h=index,store.size
Except:
除了:
a. its responses are not in json so easily referencing it using the ng-repeat <li>elements isn't going to work; and
一种。它的响应不在 json 中,所以使用 ng-repeat<li>元素很容易引用它是行不通的;和
b. i would like, if possible, to get the size output to reflect the same unit size (like bytes).
湾 如果可能的话,我希望得到大小输出以反映相同的单位大小(如字节)。
If this involves something complicated then I'd be grateful for pointers on where I should focus.
如果这涉及一些复杂的事情,那么我会很感激我应该关注的地方。
I am using elasticsearch v1.4.4
我正在使用 elasticsearch v1.4.4
Many thanks
非常感谢
采纳答案by Prabin Meitei
Index size in bytes is included with an indices stats API call:
索引大小(以字节为单位)包含在索引统计 API 调用中:
curl http://localhost:9200/_stats/indexing,store
curl http://localhost:9200/_stats/indexing,store
For nicely formatted JSON output, append ?prettyto the end of the URL:
对于格式良好的 JSON 输出,将?pretty附加到 URL 的末尾:
curl http://localhost:9200/_stats/indexing,store?pretty
curl http://localhost:9200/_stats/indexing,store?pretty
See the Indices stats API documentationfor additional details and related information.
有关其他详细信息和相关信息,请参阅指数统计 API 文档。
回答by Olivier
I realize this question dates already, but wanted to add my 2 cents.
我已经意识到这个问题的日期,但想加上我的 2 美分。
http://localhost:9200/_cat/indices?h=index,store.size&bytes=kb&format=json
http://localhost:9200/_cat/indices?h=index,store.size&bytes=kb&format=json
Would actually get you exactly what you requested:
实际上会得到你所要求的:
- format=json-> formats the output to json
- bytes=kb-> outputs the size in kilobytes
- format=json-> 将输出格式化为 json
- bytes=kb-> 以千字节为单位输出大小
Information regarding the size unit was retrieved from cat APIs doc
从cat APIs doc检索到有关大小单位的信息
Possible valuesfor the bytes argument
bytes 参数的可能值
Information regarding the format was an attempt in Sense, which has some auto-completion features quite useful to detect such options.
有关格式的信息是 Sense 中的一种尝试,它具有一些自动完成功能,对于检测此类选项非常有用。
Cheers.
干杯。
回答by sonu1986
Just a slight modification from above answer.
只是对上面的答案稍作修改。
curl -X GET "localhost:9200/_cat/indices?h=index,store.size&bytes=gb?pretty"
curl -X GET "localhost:9200/_cat/indices?h=index,store.size&bytes=gb?pretty"

