Splunk Search

How to chart the percentage of errors per server over time?

fc_splk
Engager

Hi,

Considering a set of servers, I would like to plot the percentage of errors for each server over time. I am trying to create one view with a line for each server.

I managed to get a statistics table with the following query and tried to pipe something like "xyseries _time, host, percent", but this doesnt work.

 ... |  chart count(eval(responseCode like "2%")) AS success, count(eval(NOT responseCode like "2%"))  AS failure by host | addtotals fieldname=Total success, failure | eval Errors_Percentage=round(failure*100/Total)

I tried with a timechart as well, but then didn't manage to add the percentage field for each span/host.

Thanks!

0 Karma
1 Solution

sundareshr
Legend

This, I think, should give you the chart you're looking for

... | eval httpstatus=if(status>299, "Failed", "Success") | bin _time as t span=1d | eval time_host=t."@".host | chart count over time_host by httpstatus | addtotals | eval Perc=Failed/Total*100 | rex field=time_host "(?<Time>\d+)@(?<Host>\w+)" | table Time Host Perc | fieldformat Time=strftime(Time, "%Y/%m/%d") | xyseries Time Host Perc

View solution in original post

sundareshr
Legend

This, I think, should give you the chart you're looking for

... | eval httpstatus=if(status>299, "Failed", "Success") | bin _time as t span=1d | eval time_host=t."@".host | chart count over time_host by httpstatus | addtotals | eval Perc=Failed/Total*100 | rex field=time_host "(?<Time>\d+)@(?<Host>\w+)" | table Time Host Perc | fieldformat Time=strftime(Time, "%Y/%m/%d") | xyseries Time Host Perc
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...