How to calculate the percentage of a metric through JSON?

Hi!
I'm new with Elastic so this is most probably an easy question but I would appreciate some help here.

I have a dashboard on Kibana where I want to add a vertical bar chart which presents me the results of the tests I perform for each country. The result of each test can be either 'successfull' or 'failed'.
So as an example, on this bar chart, I could have the results for three countries (e.g. Spain, UK, Netherlands) hence I would have three bars (one for each country) and each bar would present me the percentage of Successful tests executed and the percentage of Failed tests.

I've tried to this with the available menus but percentage is not an option on the aggregation field and percentiles does not work here. I assume I can do this with the advance JSON input field but not sure how. Can someone shed some light here?

Thanks in advance!

Hi @rcmv ,

Probably the easiest way to achieve it is to use Lens Donut visualisation, here is an example I made with pre-existing sample data:

basically you can slice once by country and 2nd time by result.

You did not mention the stack version you are using, so I wonder if you have Lens or old Pie Chart.

Regards, Dima

Hi,

You can also use "Bar vertical percentage" in Lens visualizer.