Created
February 6, 2025 07:27
-
-
Save felixbarny/213117a5d641cc67fb242c43db915d31 to your computer and use it in GitHub Desktop.
Handy scripts to analyze the disk_usage output from Elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo field, total, doc_values, inverted_index, points | |
curl -s $1 | | |
jq -r '. | |
| to_entries | |
| .[] | |
| select(.key != "_shards") | |
| .value.fields | |
| to_entries | |
| .[] | |
| "\(.key), \(.value.total_in_bytes), \(.value.doc_values_in_bytes), \(.value.inverted_index.total_in_bytes), \(.value.points_in_bytes)"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo category, total, doc_values, inverted_index, points | |
curl -s $1 | | |
jq -r ' | |
. | to_entries | |
| .[] | |
| select(.key != "_shards") | |
| .value.fields | |
| to_entries | |
| map({ | |
field: .key, | |
category: (if .key | startswith("_") then "meta" | |
elif .key == "@timestamp" then "@timestamp" | |
elif .key | startswith("attributes") then "attributes" | |
elif .key | startswith("resource.attributes") then "attributes" | |
elif .key | startswith("metrics") then "metrics" | |
else "other" | |
end | |
), | |
total_in_bytes: .value.total_in_bytes | tonumber, | |
inverted_index_total_in_bytes: .value.inverted_index.total_in_bytes | tonumber, | |
doc_values_in_bytes: .value.doc_values_in_bytes | tonumber, | |
points_in_bytes: .value.points_in_bytes | tonumber | |
}) | |
| group_by(.category) | |
| map({ | |
category: .[0].category, | |
total_in_bytes: map(.total_in_bytes) | add, | |
inverted_index_total_in_bytes: map(.inverted_index_total_in_bytes) | add, | |
doc_values_in_bytes: map(.doc_values_in_bytes) | add, | |
points_in_bytes: map(.points_in_bytes) | add | |
}) | |
| .[] | |
| "\(.category), \(.total_in_bytes), \(.doc_values_in_bytes), \(.inverted_index_total_in_bytes), \(.points_in_bytes)"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment