Solar power monitor. Sum between alerts

I am using Grafana to present data from an InfluxDB datasource which is being fed with PV solar power generation data every 10s. I have set up alerts to control the charging of my EV (Nissan Leaf). I turn on the charger when solar power generation is above the alert threshold. I would like to be able to compute the total Kwh generated between the “Alert OK” (power above threshold - charger on) and an “Alert” (power below threshold - charger off)
Any recommendations as to how I could do this would be appreciated.