how do i calculate average query and fetch time on my elasticsearch server. http://mysearver.com:9200/_stats gives me the query_time and fetch_time. But this values keep incrementing on each search. I need avg query time and fetch time of the querys and plot it on a graph.
I tried query_time/query_total , this value also increase on each query and then stays on that after the query has stopped.
This is what i have tried so far
url = 'http://localhost:9200/_stats'
raw_data = urllib2.urlopen(url)
data = json.loads(raw_data.readline())
QueryTime = data['_all']['total']['search']['query_time_in_millis']
QueryTotal = data['_all']['total']['search']['query_total']
AvgQueryTime = QueryTime/flaot(QueryTotal)