Last active
August 27, 2018 17:00
-
-
Save jcantrill/94c092ee0fbf725bd589347aacf10471 to your computer and use it in GitHub Desktop.
This script finds the old index patterns that match the 'project.*.*.*.*' and removes them from the .kibana index
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
#!/bin/bash -e | |
POD=$1 | |
SIZE="${SIZE:-1000}" | |
index=".kibana" | |
oc exec -n logging -c elasticsearch $POD -- es_util --query="$index/index-pattern/_search?pretty&stored_fields=_id&size=$SIZE" | grep id | grep project\..* | cut -d ':' -f 2 | cut -d '"' -f 2 | paste -sd " " > patterns | |
echo '' > payload | |
for p in $(cat patterns); do | |
echo "{\"delete\":{\"_index\":\"${index}\", \"_type\":\"index-pattern\", \"_id\":\"$p\"}}"i # >> payload | |
done | |
cat payload | |
oc cp -n logging payload $POD:/tmp/payload -c elasticsearch | |
oc exec -n logging -c elasticsearch $POD -- sh -c 'es_util --query=_bulk?pretty -XPOST --data-binary @/tmp/payload -H "Content-Type: application/x-ndjson"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment