Kibana filters aggregation using "from" and "to" values from Time Picker

Hi!

Is it possible to use the "from" and "to" values from the Time Picker in a filters aggregation with a date field?
I know i can use fixed values like "now-7d" but i'd like to filter accordingly with the period selected in the Time Picker. The date field i'm using is different from the Time Filter field on the index pattern.

Thanks in advance!

Hi @tnarciso and welcome to the community!
Assuming that you're asking to correlate the "from" and "to" values from the Time Picker that uses one field that's different to the field you want to use in the filter aggregation, there isn't an automatic way to do that. I'd recommend taking a look at the corresponding values for the two fields using something like Discover.

You could also try adding a scripted field or a runtime field if you're using version 7.11+. You can read a bit more about runtime fields here and scripted fields here.

Hi @cheiligers and thank you for your reply!

I'm not sure how i could achieve this via scripted fields, and i'm running version 7.9.1.

Let's say my documents have 3 date fields: "lastUpdatedDate", "createdDate" and "resolvedDate" (with "lastUpdatedDate" being the time filter field on my index pattern).

What i'm trying to achieve is to create a vertical bar chart with a Date Histogram using "lastUpdatedDate" as the X-axis and then split this series with a Filters aggregation by "createdDate" and "resolvedDate".

So whatever the time period is selected via the Time Picker the chart would show the document count for each filter using the same time period (i'm using "submittedDate >= now-7d and submittedDate < now" as one of the filters now but this needs to be dynamic).

@tnarciso Date Histograms use the index date field (usually timestamp) by default as the x-axis and AFAIK, there's not way of changing that to some other date field.
You will need to use Lens that gives a lot more flexibility on the data you can specify.
If you haven't used Lens before, there are some great tutorials and I'd start by going through these.

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