Splunk Search

splunk search giving same results in table

leomedina
Explorer

Hello,

The below search is producing the same data for success and errors...

index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code"
| lookup http_response_codes.csv response_code OUTPUT description
| stats count as Success by ApplicationName
| append [search index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code" 
| stats count as Errors by ApplicationName]
| stats values(Success) as Success, values(Errors) as Errors by ApplicationName

1) How can I make this query output the data where it needs? Do I need to create multiple lookups (one for successful and one for errors)? My http_response_codes.csv has a ton of response codes. If so, how would that search look like? Greatly appreciate the help.

0 Karma
1 Solution

woodcock
Esteemed Legend

Try this:

 index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code"
| lookup http_response_codes.csv response_code OUTPUT description
| stats count(eval(match(description, "success"))) AS Success count(eval(match(description, "error"))) AS Errors BY ApplicationName

View solution in original post

0 Karma

woodcock
Esteemed Legend

Try this:

 index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code"
| lookup http_response_codes.csv response_code OUTPUT description
| stats count(eval(match(description, "success"))) AS Success count(eval(match(description, "error"))) AS Errors BY ApplicationName
0 Karma

leomedina
Explorer

Thank you Mr. Woodcock!

I made some minor modifications on my end but your guidance led me there. I ended up creating a new lookup csv with the status of success or fail in a separate column next to the http codes and was then able to use the above query.

Thanks again!

0 Karma

woodcock
Esteemed Legend

Be sure to Upvote any helpful answers and click Accept on the best one to close the Question and let others know what worked.

0 Karma

andrey2007
Contributor

Hello, leomedina

It looks that you should correct stats statement because now you count the same in first search and after append

1.index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code"
...
| stats count as Success by ApplicationName

2.[search index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code"
| stats count as Errors by ApplicationName]

but rename in different ways Success and Errors

May be you should try something like this to specify some way in first case only success and in second only errors

 index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code"
 | lookup http_response_codes.csv response_code OUTPUT description
 | search description="*success*"
 | stats count as Success by ApplicationName
 | append [search index=datapower ApplicationName="mpgw(OAuth-subscription)" "HTTP response code" 
 | lookup http_response_codes.csv response_code OUTPUT description
 | search description="*error*"
 | stats count as Errors by ApplicationName]
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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...