Creating area chart based on data that contains time ranges

I have data in the below form which tells between [start_time, end_time] I have processed "total_bytes_processed" data and my average processing power in that duration was "average_bytes_processed_per_second" (can be computed from the remaining 3 fields as well).

{
"start_time": "2019-05-01 01:00:00.000Z",
"end_time": "2019-05-04 01:00:00.000Z",
"total_bytes_processed": 102345,
"average_bytes_processed_per_second": 12
}

My requirement is to aggregate "average_bytes_processed_per_second" across overlapping intervals of [start_time, end_time] and show as an area chart.

For eg if the dataset is having 2 records like below:

[{
"start_time": "2019-05-01 00:00:00.000Z",
"end_time": "2019-05-03 00:00:00.000Z",
"total_bytes_processed": 102345,
"average_bytes_processed_per_second": 12
},
{
"start_time": "2019-05-02 00:00:00.000Z",
"end_time": "2019-05-05 01:00:00.000Z",
"total_bytes_processed": 102345,
"average_bytes_processed_per_second": 12
}]

then the output area chart will show data in somewhat below form (where from_time and to_time show the start and end time for a particular value on x-axis):

[{
"from_time": "2019-05-01 00:00:00.000Z",
"to_time": "2019-05-02 00:00:00.000Z",
"average_bytes_processed_per_second": 12
},
{
"from_time": "2019-05-02 00:00:00.000Z",
"to_time": "2019-05-03 00:00:00.000Z",
"average_bytes_processed_per_second": 17
},
{
"from_time": "2019-05-03 00:00:00.000Z",
"to_time": "2019-05-05 00:00:00.000Z",
"average_bytes_processed_per_second": 5
}]

I have tried a few things but I haven't been successful yet, so wanted to know how would others do it?

PS: I don't have access to change source data format/type.

Hey @samkit -- would something like this achieve what you are looking for?

  • Create an area chart
  • Under Metrics, set a Sum aggregation on average_bytes_processed_per_second
  • Under Buckets, do a Date Histogram aggregation on start_time, with your interval set to daily

A vertical bar chart would probably be even clearer in this case, as you'd have one bar for each day, with the sum of total bytes processed per second for that day.

Ah actually, as I think about this, I'm not 100% certain this will calculate the sum as you want it to -- but either way let me know what you find.

Hi @lukeelmers - yeah this is not what I want. I also want to consider range between start_time and end_time. What you suggested will work if I had just single timestamp field but I have a time range which i want to consider.

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