[Feature] Aggregation of 2 columns


(Summer Nguyen) #1

Hello,
I'm new to Kibana and Elasticsearch, I used Kibana and Elastic Search for our log aggregation.
My data is simple like this : id , time , username , spentGold , earnGold .
I can make line charts :

  • Total SpentGold hourly
  • Total EarnGold hourly.

Now, I want to get a chart :

  • ( Total EarnGold / Total SpentGold ) hourly.

Does Kibana support it now , how can I make it.
Thank you very much.

Update 1 :
in my any log rows : SpentGold and EarnGold can not be both positive numbers .
if SpentGold > 0, then EarnGold =0
if EarnGold >0 , then SpentGold =0
SpentGold and EarnGold sometimes can be both = 0 .


(Tyler Smalley) #2

This can be done using a scripted field. The easiest way is to add on the index pattern under settings.

For example:

doc['Total EarnGold'].value / doc['Total SpentGold'].value


(Summer Nguyen) #3

Hello,
Sorry about unclear data .
in my any log rows : SpentGold and EarnGold can not be both positive numbers .
if SpentGold > 0, then EarnGold =0
if EarnGold >0 , then SpentGold =0

SpentGold and EarnGold sometimes can be both = 0 .
So I can not make a scripted field like this way .
I think there some kind of aggregation features in the visualize it self to calculate every hours.

Do you have any idea about it.
Thank you very much,


(system) #4