I have a Grafana dashboard that has Elasticsearch as its datasource. The JSON logs are parsed using the Extract Fields
transformation and have a table that looks something like this
ID | Field1 | Field2 |
---|---|---|
A | [ “Value-1”, “Value-2” ] | Example 1 |
B | [ “Value-1” ] | Example 2 |
C | [ “Value-2”, “Value-3” ] | Example 3 |
I want to count the occurrences of each value inside the list of Field1
. For example, this is the desired table that I want to create.
Field1 | Count |
---|---|
“Value-1” | 2 |
“Value-2” | 2 |
“Value-3” | 1 |
My initial approach was to figure out a transformation that could convert the list values into separate rows. Then, I could do a Group By
transformation and count each value. But I cannot find a transformation that could do what I have described. The table would look like this:
ID | Field1 | Field2 |
---|---|---|
A | “Value-1” | Example 1 |
A | “Value-2” | Example 1 |
B | “Value-1” | Example 2 |
C | “Value-2” | Example 3 |
C | “Value-3” | Example 3 |
Is there a way to do such transformation? Or is there a better approach I should take?