I'm trying to programatically determine when Kibana is ready to serve requests and therefore calling the status api /api/status.
Expected behaviour
Until Kibana is up and ready to receive requests I would expect /api/status to return something other than 200.
Actual behaviour
/api/status initially returns 503
At some point the optimization step is complete which will be logged as:
[info][optimize] Optimization success in 2.83 seconds
At this point /api/status will return 200. However opening Kibana in the browser will still return an error message: "Elastic did not load properly. Check the server output for more information."

After about 60 seconds Kibana will output:
[success][@kbn/optimizer] 88 bundles compiled successfully after 297.9 sec, watching for changes
Kibana will now be truly ready to serve requests
Reproduce
This only seems to happen in a bare repository without any cached artefacts - at all! The easiest way to get to this state is by wiping all build files find {x-pack,src} -type d -name "target" | xargs rm -rf .
Cold start Kibana:
find {x-pack,src} -type d -name "target" | xargs rm -rf && yarn kbn bootstrap && node ./scripts/kibana --no-base-path --dev --elasticsearch.username admin --elasticsearch.password changeme --elasticsearch.hosts http://localhost:9200
Poll the status endpoint while Kibana is starting:
for run in {1..1000}; do curl -s -o /dev/null -w "%{http_code}\n" -u admin:changeme localhost:5601/api/status; sleep 0.5; done
Note: you should be able to remove the credentials if you are connecting to an ES without security enabled
I'm trying to programatically determine when Kibana is ready to serve requests and therefore calling the status api
/api/status.Expected behaviour
Until Kibana is up and ready to receive requests I would expect
/api/statusto return something other than 200.Actual behaviour
/api/statusinitially returns 503At some point the optimization step is complete which will be logged as:
At this point
/api/statuswill return 200. However opening Kibana in the browser will still return an error message: "Elastic did not load properly. Check the server output for more information."After about 60 seconds Kibana will output:
Kibana will now be truly ready to serve requests
Reproduce
This only seems to happen in a bare repository without any cached artefacts - at all! The easiest way to get to this state is by wiping all build files
find {x-pack,src} -type d -name "target" | xargs rm -rf.Cold start Kibana:
Poll the status endpoint while Kibana is starting:
Note: you should be able to remove the credentials if you are connecting to an ES without security enabled