Water rocket - measuring altitude with the accelerometer

I would like to launch a water rocket and send the micro:bit along. It should measure how high the rocket flew and preferably also how fast the rocket flew… Does anyone have a code idea? Thanks a lot in advance.
aha-ha