I'm trying to find out the results from a search query (ie: searching results for the given date range) of a particular index. So that I could get the results in a daily basis.
In the above, timestamp is a field which i added using my logstash.conf in order to get the actual log time. When i tried querying this, surprisingly i got a number of hits (total hits: 24) which should've been 0 since I didn't have any log records from the date of (2016-08-03) . It actually displays the count for the next day (ie: (2016-08-04), which has 24 records in the log file. I'm sure something has gone wrong with the timezone.
The timezone will be stored as UTC, so if you want to get events during a calendar day in local time you have to adjust your query accordingly. If you make the query using the query DSL rather than a query string you can use a range query and set the timezone option to make ES do the timezone adjustment for you.
Thanks for the reply. I was doing the querying (GET request) through postman without using the CURL.
If you make the query using the query DSL rather than a query string you can use a range query and set the timezone option to make ES do the timezone adjustment for you.
I didn't quite understand how could i make the query using query DSL if I'm going to test it through Postman kinda thing and how am I going to use the range query in there for a GET request?
That's the wrong solution to the problem since you'll be storing local time as UTC while ES and Kibana continue to assume that the stored timestamps are UTC when they're in fact local time.
How could I make both ES & Kibana tally with the same timezone so I don't mess with it?
I didn't quite understand how could i make the query using query DSL if I'm going to test it through Postman kinda thing and how am I going to use the range query in there for a GET request?
How could I make both ES & Kibana tally with the same timezone so I don't mess with it?
Insert the timestamps as UTC (the date filter will do the conversion for you based on the server's timezone, but otherwise you can override it with the timezone option) and either use UTC for all other direct interaction with ES. In some cases, like the range query's timezone option you can specify which timezone you want things.
How can I proceed with the above ?
The ES documentation contains plenty of pages with examples about the query DSL.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.