Filter elasticsearch's query by timerange

I am getting my datasource from elasticsearch and I would like to get the count of statusCode:200 in the last 5min (filtered by the top timerangee Last 5 minutes)

My settings are

Visualization: Stat
Display → Value → Count

Query A: environment:dev and serviceID: “myserviceid” and statusCode: 200
Metric Count
Group By: Date Histogram - @Timestamp

However, even when no logs are coming into elasticsearch, the sum will still include data which is supposed to show 0.

Would it be possible to filter my query by the timeframe selected at the top? like

query: environement:dev and serviceID: “someservice” and statusCode:200 and @timestamp: $timeframe

Hello, you could filter the query by the timeframe selected at the top.

i am trying to do that, however not able to get the correct data out

ok should work what data do you get?

yes, mistake was had to use big AND instead of small ones