Skip to content

Instantly share code, notes, and snippets.

@TomonoriSoejima
Last active December 14, 2020 03:13
Show Gist options
  • Save TomonoriSoejima/7e69e5603ca610fb52298937401a2210 to your computer and use it in GitHub Desktop.
Save TomonoriSoejima/7e69e5603ca610fb52298937401a2210 to your computer and use it in GitHub Desktop.
push data to elastic cloud.md
# get the deployment id and name.
# ecctl deployment list  | jq -r '.deployments[] | .id, .name'

short_deploymnent_id=$(echo $1|  cut -b -6)

credentials=$(find . | grep --color=never $short_deploymnent_id | xargs grep -v username | sed -e s/\,/\:/ -e s/,true//)

endpoint=$(ecctl deployment show $1 |  jq -r '.resources.elasticsearch[0].info.metadata | (.endpoint + ":" +  (.ports.https|tostring))')

url="https://$endpoint"
cat data.json  | http --quiet -a $credentials POST $url/_bulk
  • assuming that you have downloaded credentials already on the current directory.
[nami:kibana_cloud]$ ls -1
credentials-5d388b-2020-Dec-14--11_02_47.csv
credentials-803051-2020-Dec-14--10_51_20.csv
data.json
push.data.sh
[nami:kibana_cloud]$ 
  • usage

[nami:kibana_cloud]$ ecctl deployment list  | jq -r '.deployments[] | .id, .name'
803051d2e7bf4b6c97752621f9183e82
771
5d388b101c784eb983a30c73d846720c
791
[nami:kibana_cloud]$ sh push.data.sh 803051d2e7bf4b6c97752621f9183e82
[nami:kibana_cloud]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment