Custom Metric - Calculating the error %

I need to calculate the error percentage based on the success and failure rate for a request. Lets say i have Login request where i have to calculate based on the code i receive (200 and 500/404). How can i achieve error percentage here? I need to achieve this as part of Data Table (Visulaize).

Tipically people display the response codes using a bar chart, but with some wizardry we can do a success rate in the data table using scripted fields.
I created a scripted field, called success, that has the following script:

if (doc['response.raw'].value == "200") {
return 1;
}
return 0;

Then you set it's format to Percentage from that same edit page.

Now you can do an Average of the success field in the data table and this will show the percentage of successful requests.

This is how it looks on some randomly generated Apache logs (using makelogs from the Kibana repo):

1 Like

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