Unable to apply complex queries with Elasticsearch as datasource

Hi All I am pulling logs/traces data from Elasticsearch into Grafana. Need to calculate the latency of the applications which are pushing data into ES as per the below SLO:

the latency of all user requests (as computed every 10 minutes) will be less than 300 milliseconds 99.5 percent of the time in any 30 day period.

I used the Meta queries plugin for the arithmetic calculation but at one time either i can calculate for 10 min or 30 days but not at both the level at the same time.

Any pointers for the same would be helpful.

Can you post the detail query here? I just lost of understanding…