Creating a visualization from a script query

I need to create visualizations after doing some math on the indexed data.
I went through this: https://www.elastic.co/guide/en/elasticsearch/painless/5.5/painless-examples.html
where it shows the usage using REST APIs.
Now I want to do the same using Kibana.
If we take the same example, how can I generate a bar chart where I can see the player name on X-axis and total number of goals scored on the Y axis?
Thanks.

Ohh. Actually i was using the wrong Aggregation for X-axis due to which I wasn't getting the option to 'run' the visualization.
With this configuration I was able to generate the chart.
Y-axis: Aggregation: Max, Field: Goals.
JSON Input:
{
"script": {
"lang": "painless",
"inline": "int total = 0; for (int i = 0; i < doc['goals'].length; ++i) { total += doc['goals'][i]; } return total;"
}
}

X-axis: Aggregation Terms, Field: first.keyword

I would try (I am using ELK5.4)
Create a query where you select those event you need. Then visualisations -> vertical bar
Change the Y-Xasis to Sum() and select the field that hold the goals for the users. Select bucket type X-Axsis -> term aggr and select the users name.

Paul.

Yes, this works too and is the proper way for such a query. Thanks.

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