Subtract document count for different field names in Kibana

Hi,

I have following easy schema of my ES document:

videoAsin
eventName

Video asin is unique identifier of video we store.
eventName may have different values. For example, “event1”, “event2”, “event3”, etc

I need to get following dashboard in Kibana:

For each videoAsin, get count of documents with eventName = “event1” and subtract count of documents with eventName = “event2” for the same videoAsin.

Is it possible to achieve so using Kibana? I have newest version

Hello,
A solution that I came up with would be to create a scripted field that is something like this:

if doc["eventName"] == "event1" {
return 1 } 
if doc["eventName"] == "event2" {
return -1}
return 0

Now you can do a chart with a Sum metric on the scripted field and a split by Terms on videoAsin.

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