Skip to content

Instantly share code, notes, and snippets.

@mohclips
Created March 20, 2021 17:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mohclips/163e2e21fd3f5576b0659acf7982ca35 to your computer and use it in GitHub Desktop.
Get a simplistic view of an ElasticSearch template
#!/bin/bash
ES="192.168.0.2:9200"
INDEX="stats-000001"
curl -s -XGET "http://$ES/$INDEX/_mapping " |\
jq -r --arg INDEX "$INDEX" '.[$INDEX].mappings.properties |
[leaf_paths as $path |
{"key": $path | join("."), "value": getpath($path)}] |
from_entries' |\
grep -v fields |\
sed -e 's/.type": "/: "/'
{
"@timestamp: "date",
"avg_doc_size: "float",
"daily_size: "float",
"doc_count: "long",
"index: "text",
"name: "text",
"query_count: "long",
"size_in_bytes: "long",
"tags: "text",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment