question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Querying for a range of dates.

See original GitHub issue

Hello Honza, I’m hoping you might be able to help me out with one last issue i’m having. I need to query for all articles that have 404 errors as a response field and I also need to find all of them from withing the lasts 15 inutes. The issues show up inside of Kibana but they are not showing in my queries.

I’ve been having a really hard time getting this to work and there aren’t any clear examples of querying in a specific range of time in the docs. Here’s my script.

s = Search(using=es, index= "_all") \
        .query("match", response = "404")\
        .filter('range', timestamp={'from': datetime.datetime.now() - datetime.timedelta(minutes=15), 'to' : datetime.datetime.now() }) #, 'lte': datetime(2010, 10, 9)})
        #.filter("range", '@timestamp': {"gte": "now-15m", "lte": "now"}) #, "lt" : "2014-12-31 1:00:00"}) 
        #filter is for a range of possible times. 
        #.filter("range", timestamp={ "gt":"now -5m","lt":"now" })
response = s.execute()

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

9reactions
honzakralcommented, Jan 5, 2015

No, this is neither a logstash problem, nor is it a problem with the library. You are missing ** in front of the dict, it should be:

.filter('range', **{'@timestamp':{'gte': 'now-5m' , 'lt': 'now'}})

Also please stop appending questions to this ticket, this is really not the place to help you and I will not respond to any more questions here. Feel free to contact me another way. Thank you

7reactions
honzakralcommented, Jan 5, 2015

use **{'@timestamp': {'gte': 'now-5m' , 'lt': 'now'}}

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I write a SQL query for a specific date range and date ...
For example, I want to query all the rows from 5:00PM on 16-Sep-2010 to 9:00AM on 21-Sep-2010. Any ideas as to how the...
Read more >
How to Write a SQL Query For a Specific Date Range and ...
SELECT * FROM TABLE_NAME WHERE DATE_TIME_COLUMN BETWEEN 'STARTING_DATE_TIME' AND 'ENDING_DATE_TIME';. Step 1: Create a Database. For this use ...
Read more >
Selecting records between two date range query - Plus2net
Records of different date ranges by using DATE_SUB(), CURDATE() and BETWEEN() query.
Read more >
Examples of using dates as criteria in Access queries
Here are some common date criteria examples, ranging from simple date filters to more complex date range calculations. Some of the more complex...
Read more >
SQL BETWEEN Operator - W3Schools
The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates. The BETWEEN operator is inclusive: begin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found