Open Leaf-Lin opened 3 years ago
Pinging @elastic/es-core-features (Team:Core/Features)
This feature is becoming more valuable now that the documentation recommends sizing heap based on field counts
Seems we have field counts with Field Usage Stats api, but it's not so consumable with some top level counts.
GET /*/_field_usage_stats
Output is per shard and recursive, so getting totals is still a manual exercise.
Potential for a feature request to add some extended
parameter to do recursive field counts and show totals at each level.
And it's only doing actively used fields not all fields in the mapping? So that could be something that extended could also do.
https://www.elastic.co/guide/en/kibana/master/data-views-api-get.html#data-views-api-get works to get the raw info similar to the Kibana UI screenshot, but it doesn't get us a fields.count value which would be extremely valuable.
Seems we have field counts with Field Usage Stats api, but it's not so consumable with some top level counts.
GET /*/_field_usage_stats
This returns field usage information - I'm not seeing a field count in the output.
Sorry I meant the response returns the lists of fields but counting them is something you need to do manually.
Bump. Is there any chance of getting this in the near term? Elasticsearch has already imposed a field limit via index.mapping.total_fields.limit
for quite some time and having field count information available would be very useful for understanding the usage, especially for dynamically mapped indices. One shouldn't have to be a JQ 🥷 or require Kibana to get the index field count!
Today, there's an API to get per index field or all fields:
which returns:
But the output from the above doesn't have break down by index, so it's not easy to troubleshoot which index is having mapping explosion problem.
I can potentially loop over my indices list and running
GET <index>/field_caps?fields=*
API to extract the field length per index, but again, this is not ideal.It would be most useful if Elasticsearch can have an API out-of-the-box to count the number of fields breakdown by the indices, expected output should look like:
This can be part of the
GET indices/stats
orcat indices
API.Btw, kibana might be able to take advantage of the API instead of doing its own aggregation/counting to show index pattern field count:
Not sure if the following is the best script to extract the field count, but with some
jq
over theGET _mapping
output, I am able to get the desired format: