I am having trouble with some date math. I read through the docs but couldn't get things working right.
How does “/d” work? Does "now-1M/d" get me the start of this month, or should I use "now-1M" to get the start of this month? (Docs didn't help me much here.)
I want to get hits beginning on the first of the current month.
To get hits from the beginning of today, I would just mirror the correct query with "d" instead of "M"?
I am also having trouble just getting hits from yesterday.
Would this (partial) query get hits from the beginning of yesterday until the end of yesterday?
"filter": {
"bool": {
"must": [
{ "range": { "@timestamp" : { "gte" : "now-2d/d" }}},
{ "range": { "@timestamp" : { "lte" : "now-1d/d" }}}
]
}
},
I also tried this (partial) query to get only the data the beginning of yesterday until the end of yesterday:
"filter": {
"bool": {
"must": [
{ "range": { "@timestamp" : { "gte" : "now-1d/d" }}},
{ "range": { "@timestamp" : { "lt" : "now/d" }}}
]
}
},
Which seemed to work better than the above query, but it is retrieving data from 2 days ago (so if it is the 16th, it is retrieving hits from the 14th. I only want data from 00:00:00 on the 15th through 23:59:59 on the 15th (or through the next 00:00:00, whatever is easiest; I am not picky about the second lost).
Finally, how would I get hits from whatever day yesterday was, last year? (If today is the 8/16 of 2015 then I would want hits from the 8/15 of 2014.)
Many thanks for any help in clearing these up for me.