Use Dynamic value of Kibana's interval in groovy script

i want to use the value of interval which user will select through interval's dropdown in my groovy code.
Any thoughts about how to do it

when i do this, its give error about interval variable unknown. help will be much appreciated?

I don't believe the properties of the query/agg are available to the script. You might ask in the Elasticsearch forum though.