Created
September 21, 2018 13:10
-
-
Save puttpotsawee/73f850b2e39505683d2fe9289b453a83 to your computer and use it in GitHub Desktop.
This file contains 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 | |
OLD_CLUSTER=localhost:9201 | |
NEW_CLUSTER=localhost:9202 | |
OLD_CLUSTER_SERVICE=logging-elastic-service-old:9200 | |
indices=$(curl $OLD_CLUSTER/_cat/indices | awk '{ print $3 }') | |
for index in $indices ; do | |
# get your indices prefix, write this regex to grasp your indices but skip .kibana index | |
if ! [[ $index =~ ^log.*$ ]]; then | |
continue | |
fi | |
printf "\n=====Creating index mapping for ${index}=====\n" | |
# Don't forget to add your mapping into the payload | |
curl -XPUT "${NEW_CLUSTER}/${index}" -H 'content-type: application/json' -d '{"settings":{"number_of_shards":2,"number_of_replicas":1},"mappings":{<<YOUR_MAPPING_GORES_HERE>>}}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment