Filter data in kibana based on begin date and end date

Hello,

I have a table with information and a begin date and an end date.
I want to be able to filter data that are valid in the given interval.
Do you have an idea on how to do this?

Thanks!

Because data views (previously index patterns) have just one date that is used for date range queries on any kibana application that shows the time filter, there is no direct way to do this that I can think of without removing the date from the data view.

Let me use an example:

First create an index with a text field and begin and end fields:

PUT delete_test_range
{
  "mappings": {
    "properties": {
      "id": {"type": "text"},
      "begin": {"type": "date"},
      "end": {"type": "date"}
    }
  }
}

PUT delete_test_range/_bulk
{ "index" : {}}
{ "id" : "doc1", "begin": "2020-01-01T12:22:44+0200", "end": "2022-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc2", "begin": "2020-01-01T12:22:44+0200", "end": "2023-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc3", "begin": "2021-01-01T12:22:44+0200", "end": "2022-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc4", "begin": "2022-01-01T12:22:44+0200", "end": "2022-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc5", "begin": "2022-01-05T12:22:44+0200", "end": "2022-08-04T12:22:51+0200" }

Then create a data view without a timestamp metadata:

Now you can save a search in Discover to get your table ready for dashboards

And finally you can add in dashboard your search and use the filter pills to specify your interval because they compose toguether:

Peek 2022-05-04 12-38

If you check the Inspect tool of the saved search (available from the gear in the corner of the panel) you can see how Kibana builds the query using the filter pills

Hope it helps!

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