Date range value for data table

Is there a way to obtain the value of the date range in terms of start and end times, last x mins, etc...

I would like to put this value into a data table.

i.e.

Animal     Number     Date range      Average
                        (mins)       (per min)
Dogs         30           15             2
Cats         90           15             6

Can you provide some more information like your index mapping and some sample documents?

Kibana does not support ranges yet but you could store the range in the document or use a scripted field to calculate the range at query run time.

I might have not made my question clear.

I was speak to the data range query as part of the Kibana:

image

I was wondering if we could grab either the absolute or relative value.

In the above image, the user has selected relative with the value of 15.

I'm wondering if we could obtain number 15 and the unit (minutes, hours, etc...)

Thanks,

Mike

You can basically do this using the Sibling Pipeline aggregation. So for example, I have set up a table using the sample ecommerce data:

This table shows that I am calculating a Date Histogram using the interval selected, which in this case was 24 hours. So this aggregation returns the following data from Elasticsearch:

"aggregations": {
    "2": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 19,
      "buckets": [
        {
          "3": {
            "value": 32.77153188344594
          },
          "key": "Women's Clothing",
          "doc_count": 62,
          "3-bucket": {
            "buckets": [
              {
                "key_as_string": "2019-10-31T14:00:00.000-04:00",
                "key": 1572544800000,
                "doc_count": 1,
                "3-metric": {
                  "value": 59
                }
              },

So the field described as "Overall average" is actually the Average price per interval, Averaged across all the intervals. This is potentially misleading, so I would not recommend doing average of average. Maybe average of sum would be a better metric?

Thanks for your suggestion and it might be a good solution, I'll look into it.

I really want that column of showing the date range then, when I print it out, I know what date/time span we are talking about.

If you use visual builder in Kibana instead of data table, you can access the selected time bucket size

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