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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...