Filter date range "day before yesterday" in json query for logz.io api (elastic search)

1.5k views Asked by At

Context: Querying logz.io through the API.

The following query returns results for yesterday

{ "size":10000, "query" : { "bool" : { "must" : [ { "range": { "@timestamp": { "gte": "now-1d/d", "lt": "now/d" } } } ] } } }

I was hoping this one to return results for the day before yesterday

{ "size":10000, "query" : { "bool" : { "must" : [ { "range": { "@timestamp": { "gte": "now-2d/d", "lt": "now-1/d" } } } ] } } }

But it doesn't return anything. What am I missing?

1

There are 1 answers

1
Val On BEST ANSWER

You're just missing a d in the lt part

{
    "size":10000,
    "query" : {
        "bool" : {
            "must" : [
        { "range": { "@timestamp": { "gte": "now-2d/d", "lt": "now-1d/d" } } }
                                                                    ^
                                                                    |
                                                                  here
                     ]
        }
    }
}