Splunk Search

How to summarize HTTP request logs?

sahana
Engager

I have a requirement where I need to fetch the success, failure count and average response time. In events field I have entry like httpsCode and timetaken. where timetaken returns values like 628, 484 etc.... the case is like httpscode is 200 it should be treated as success count and others should be treated as failure count.... finally the statistics table should show values of success,failure and average response time....

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| stats avg(timetaken) count(eval(httpsCode == 200)) as success count(eval(httpsCode != 200)) as failure
0 Karma

sahana
Engager

i have around 25  events with  httpsCode = 200 OK but when use the above function it returns 0 in the success column

 

0 Karma

yuanliu
SplunkTrust
SplunkTrust

As @ITWhisperer suggested, you should check and post accuracy of relevant data.  I highly doubt if you have a field called httpsCode.  It is more likely httpCode, if the field is provided by Splunk at all.  If it not already extracted, you need to first extract it.  If you need help with extraction, you will need to post raw data (anonymize as needed).

More than that, a good, answerable question should illustrate desired results and explain the logic between illustrated dataset and desired results.  This relieves volunteers of the burden to read your mind.  Statistically, mind reading is more wrong than correct.

This said, I interpret your intention as to discern the count and average timetaken - again, if this field is named such and already extracted in Splunk, by "success" or "failure" status.  Maybe this will help.

| eval status = if(match(httpCode, "200|30[0-4,78]"), "success", "failure")
| stats avg(timetaken) count by status

Note that 3xx return codes are generally success statuses.  Unless you have specific reasons to classify them as "failure", they should be grouped into success.

Hope this helps.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Has httpsCode been extracted OK? Please share some sample event, anonymised of course.

0 Karma

sahana
Engager

Thanks for the info shared able to fetch the results.....

 

I have another requirement like, I want to show an bar chart which should show the total login count in basis of the time period we submit

 

for example if we select 2 days it should show the bar chart where y is for login count and x is for time slection (in basis of day interval like 6thfeb  7th feb like this)

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!

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...