Splunk Search

How to chart URLS by error code percentage

mgpspr
New Member

We are grabbing logs from nginx. I would like to know how I can chart URLS that are returning a 408 error code as well as a percentage from the overall status codes. Here is an example of what I am trying to do:

Build a chart that shows all the PUTs and POSTs requests followed by the URL, then show the percentage of the error code out of all percentage codes in the log.

"PUT /borrower/api/v1/prospect/update HTTP/1.1" 408 0
"POST /borrower/api/v1/registration HTTP/1.1" 408 51
0 Karma
1 Solution

jtrucks
Splunk Employee
Splunk Employee

First, check the nginx log parsing post on Answers for parsing your logs.

Then if you name your fields "path" and "code" you simply do something like:

... | top code limit=0 | table code, percentage | where code=408

To give you a breakdown of the percentage of codes without the default 10 items to list all options in case there are more than 10 and your 408 code is low on the list, then pull out the code and percentage only as a table, limited to only entries with the 408 code.

There are a number of other ways to slice this up, as well, but this ought to get you want you need.

--
Jesse Trucks
Minister of Magic

View solution in original post

jtrucks
Splunk Employee
Splunk Employee

First, check the nginx log parsing post on Answers for parsing your logs.

Then if you name your fields "path" and "code" you simply do something like:

... | top code limit=0 | table code, percentage | where code=408

To give you a breakdown of the percentage of codes without the default 10 items to list all options in case there are more than 10 and your 408 code is low on the list, then pull out the code and percentage only as a table, limited to only entries with the 408 code.

There are a number of other ways to slice this up, as well, but this ought to get you want you need.

--
Jesse Trucks
Minister of Magic

mikelanghorst
Motivator

Though if you're only concerned with status=408, I'd go ahead and put it in the originating search, before the "|top" shown here.

0 Karma

jtrucks
Splunk Employee
Splunk Employee

mikelanghorst, that prevents you from getting the % 408 codes of the whole.

--
Jesse Trucks
Minister of Magic
0 Karma

Fergal111
Path Finder

Is there a solution here? This will not get percentage of 408 errors over total requests.
Thanks,

0 Karma

aljohnson_splun
Splunk Employee
Splunk Employee

@fergal111 do something like

... | top url by status

^ there are any number of similar solutions

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...