diff --git a/salt/kibana/bin/so-kibana-config-load b/salt/kibana/bin/so-kibana-config-load index b06665d20..9cbfb66bd 100644 --- a/salt/kibana/bin/so-kibana-config-load +++ b/salt/kibana/bin/so-kibana-config-load @@ -1,6 +1,24 @@ #!/bin/bash -VERSION="7.6.1" -curl -X PUT "localhost:5601/api/saved_objects/config/$VERSION" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d' +KIBANA_VERSION="7.6.1" +MAX_WAIT=60 + +# Check to see if Kibana is available +wait_step=0 + until curl -s -XGET http://localhost:5601 > /dev/null ; do + wait_step=$(( ${wait_step} + 1 )) + echo "Waiting on Kibana...Attempt #$wait_step" + if [ ${wait_step} -gt ${MAX_WAIT} ]; then + echo "ERROR: Kibana not available for more than ${MAX_WAIT} seconds." + exit 5 + fi + sleep 1s; + done + +# Sleep additional JIC server is not ready +sleep 30s + +# Load config +curl -X PUT "localhost:5601/api/saved_objects/config/$KIBANA_VERSION" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d' { "attributes": { "defaultIndex": "2289a0c0-6970-11ea-a0cd-ffa0f6a1bc29", @@ -12,6 +30,5 @@ curl -X PUT "localhost:5601/api/saved_objects/config/$VERSION" -H 'kbn-xsrf: tru } }' - +# Load saved objects curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@/opt/so/saltstack/salt/kibana/saved_objects.ndjson -