Score:0

How to aggregate data according to 2 different criteria in Kibana

in flag
PCh

I am using Kibana 6.7.1

Assuming I have data having the following form (when presented in CSV format):

@timestamp,A,B,V
1,A1,B1,4
1,A2,B1,9
1,A1,B2,5
1,A2,B2,10
2,A1,B1,6
2,A2,B1,12
2,A1,B2,13
2,A2,B2,8

I would like to perform an average aggregation of V for records having identical A and B and then I would like to output sum aggregation of these averages for averages having identical A.

So with the above example, first aggregation would return:

(A;B),Average(V)
(A1;B1),5
(A2;B1),10.5
(A1;B2),9
(A2;B2),9

and the second aggregation finally would output:

A,Sum(Average(V))
A1,13
A2,19.5

I tried with the Visual Builder but I failed to use 2 different criteria to group data.

I have created a Scripted Field to concatenate A and B to allow making first aggregation on 2 criteria with a single field but I failed to use it in the Group By field of Visual Builder probably because this Scripted Field is not indexed.

I tried with Line or Horizontal Bar visualisation which allow me to subdivide a criterion with an other one. This allowed me to reach the first step but then I failed to add a second aggregation that would merge back the subdivision.

Is there a way to generate the synthesis I am trying to get?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.