Battery power monitor

I have a need to monitor my battery and get an idea of how much power remains before the device shuts down. It would also be helpful to know when to put it to sleep in an orderly manner before the program just halts on low power. I'm using the MKR GSM 1400 and it uses a BQ24195 charger chip attached to the I2C system. If anyone has links to resources I am interested.