Splunk Search

Regex inside eval is not working

pjtbasu
Explorer

I am trying to do a stats count where 2XX https response means as success and any non 2XX means that it's a failure. I am using below snippet. But it doesn't work. Am I missing something ?

 

stats  count(eval(httpresponse="2*")) as TRANSACTIONS_SUCCESS,  count(eval(httpresponse!="2*")) as TRANSACTIONS_FAILURE by service

Labels (3)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@pjtbasu 

Can you please try this?

YOUR_SEARCH
| stats sum(eval(if(like(httpresponse,"2%"),1,0))) as TRANSACTIONS_SUCCESS, sum(eval(if(!like(httpresponse,"2%"),1,0))) as TRANSACTIONS_FAILURE by service

 

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated. 

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@pjtbasu 

Can you please try this?

YOUR_SEARCH
| stats sum(eval(if(like(httpresponse,"2%"),1,0))) as TRANSACTIONS_SUCCESS, sum(eval(if(!like(httpresponse,"2%"),1,0))) as TRANSACTIONS_FAILURE by service

 

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated. 

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...