KQL Query or Elastic query to fetch data for current month

Hi all,

I'm trying to fetch data only for current month of april 2023.

For example,

I have a query filter condition in my search bar in my kibana data table as

configuredDate > now-30d

which gives me data for past 1 month.

But I want to fetch data from April 1st to April 28th 2023.
The above query fetches me data from March 30th 2023 to April 28th 2023.

I want to fetch data from 1st of the current month to current date for other queries.
This data may dynamic , but i want to fetch from 1st of current month i.e from April 1st 2023 to April 28th 2023 or current timestamp.

I cannot use timepicker for this.

Any way to go about it?

Regards

See if now/M gets you what you want. That should round it down to the nearest month.

No, the below throws an error.

configuredDate > now/M

Any other way I can show present month

So instead of using KQL, could you put the time relevant part in the query DSL. Here's the query I'm using:

GET example/_search
{
  "query": {
    "range": {
      "@timestamp": {
        "gt": "now/M"
      }
    }
  }
}

@Wave Thank you!

I tried in DSL query and it worked as below:

{
  "query": {
    "range": {
      "configuredDate": {
        "gte": "now/M"
      }
    }
  }
}

I just had to change from gt to gte & it worked!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.