How to change y-axis to show field value which is already an aggregate

I have an array of data points objects that follow this format:

{pizzasBought: 50, time:13:10}

I want the x-axis to be set to time and pizzasBought which is already an aggregate to the y-axis and was wondering how to do this in Kibana.

One way to do this, I suppose, is to write a loop that generates 50 json objects, each representing a pizza bought with property time at 13:10, like so ({time: 13:10}), but that sounds like an exercise in futility and a waste of time.

Anything that doesn't involve this method would be much appreciated.


So you're indexing data into Elasticsearch that way?

The fact the number bought is an aggregate already doesn't matter much. You're recording the number bought at a given time, but Elasticsearch (and Kibana by extension) will allow you to see the number in a given time bucket. For example, the total number bought every hour.

This is a pretty easy to accomplish. In Kibana, simply do a date-histogram agg on the X-axis and set the metric to some math operation that's not count (Max, Sum, Average, Mean, etc. are all fine). That'll bucket up the data in blocks of time and show you purchase counts over time.

yes. More precisely, I'm indexing my data as follows

index: pizzas
{pizzasBought: 50, createdAt:13:10:10, dayOfWeek: 1}

index: calls
{callsReceived: 100, hour: 23, dayOfWeek: 1}

This is over the course of 2 days so far in five second intervals. using a date histogram gives me an error "the interval creates too many buckets" when I group by hour. I'd like to get an average of the number of pizzas ordered by hour (1pm, 2pm, etc) but wasn't sure how to go about doing this. I am able to get the index calls to show up on another graph but would also like that to display on the same line chart as the one for the pizzas ordered index. Thanks.

using a date histogram gives me an error "the interval creates too many buckets" when I group by hour

That sounds very odd. Hourly buckets shouldn't be a problem... unless maybe you're trying to view a large timeframe. If you are, you may need to pick a larger bucket instead of hourly.

Can you share a screenshot of the side bar in Visualize, so I can see how you're building the visualization?

I changed things a bit and I'm not exactly which of the steps that I took resolved the issue, but the time interval issue has been resolved. I've changed the indexing format as follows:

index: pizza
type: purchase
{pizzasBought: 50, createdAt:13:10:10, dayOfWeek: 1}

index: pizza
type: calls
{callsReceived: 100, dayOfWeek: 1, createdAt: 13:10:10}

I'm now wondering how I'd be able to show the following on the same visualization:
-average number of purchases in hourly intervals
-sum of calls placed in hourly intervals

I'm now wondering how I'd be able to show the following on the same visualization

You're not going to be able to do this on the same visualization, at least not with normal visualizations in Kibana, like the basic area, line, bar, pie charts and all those. Since you have different filter requirements for those records, they are different series, and those visualizations only support a single series.

You can do this with the Visual Builder vis in Kibana though, since it supports multiple series on the same chart. In that case, you add two series, one filtered on the type: purchase and showing the sum of the pizzasBought field, and the other filtered on type: calls and showing the sum of the callsReceived.

thanks for the response. I'll look into that solution.

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