Splunk Search

Why am I not getting value in a new created field?

csharm21
Loves-to-Learn

Hi Team,

I am trying to create one SPL search and create a new field with the eval command, but I am not getting any value count on the newly created field.

Please find my query below.

index=throwaway sourcetype=GIC-EMR-Wrapper-log_V1
| stats 
count(eval(errorResponse.ResponseCode=CCEABR)) as "CCEABR Count"
count(eval(errorResponse.ResponseCode=CCEAIT)) as "CCEAIT Count"
count(eval(errorResponse.ResponseCode=CCEAEE)) as "CCEAEE Count" 
count(eval(errorResponse.ResponseCode=AESCND)) as "AESCND Count" 
count(eval(errorResponse.ResponseCode=AESCEE)) as "AESCEE Count" 
count(eval(errorResponse.ResponseCode=AERCEE)) as "AERCEE Count" 
count(eval(errorResponse.ResponseCode=CPDNA)) as "CPDNA Count"
count(eval(errorResponse.ResponseCode=CPMNF)) as "CPMNF Count"
count(eval(errorResponse.ResponseCode=CPLOB)) as "CPLOB Count"
count(eval(isnull(errorResponse.TimeStamp))) as "Timeout Count"
count(eval(errorResponse.JsonResponse="" or isnull(errorResponse.JsonResponse))) as "Success/No Error Code Count"
by requestSpecificElements.clientID requestSpecificElements.locationID
| rename requestSpecificElements.clientID as "Client ID"
requestSpecificElements.locationID as "Location ID
Tags (2)
0 Karma
1 Solution

niketn
Legend

@csharm21 add single quote for your field name inside eval expression as there is dot ( . ) special character in the field name. Try replacing stats pipe with the following ans confirm!

| stats 
count(eval('errorResponse.ResponseCode'=="CCEABR")) as "CCEABR Count"
count(eval('errorResponse.ResponseCode'=="CCEAIT")) as "CCEAIT Count"
count(eval('errorResponse.ResponseCode'=="CCEAEE")) as "CCEAEE Count" 
count(eval('errorResponse.ResponseCode'=="AESCND")) as "AESCND Count" 
count(eval('errorResponse.ResponseCode'=="AESCEE")) as "AESCEE Count" 
count(eval('errorResponse.ResponseCode'=="AERCEE")) as "AERCEE Count" 
count(eval('errorResponse.ResponseCode'=="CPDNA")) as "CPDNA Count"
count(eval('errorResponse.ResponseCode'=="CPMNF")) as "CPMNF Count"
count(eval('errorResponse.ResponseCode'=="CPLOB")) as "CPLOB Count"
count(eval(isnull('errorResponse.TimeStamp'))) as "Timeout Count"
count(eval('errorResponse.JsonResponse'=="" or isnull('errorResponse.JsonResponse'))) as "Success/No Error Code Count"
by "requestSpecificElements.clientID" "requestSpecificElements.locationID"
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@csharm21 add single quote for your field name inside eval expression as there is dot ( . ) special character in the field name. Try replacing stats pipe with the following ans confirm!

| stats 
count(eval('errorResponse.ResponseCode'=="CCEABR")) as "CCEABR Count"
count(eval('errorResponse.ResponseCode'=="CCEAIT")) as "CCEAIT Count"
count(eval('errorResponse.ResponseCode'=="CCEAEE")) as "CCEAEE Count" 
count(eval('errorResponse.ResponseCode'=="AESCND")) as "AESCND Count" 
count(eval('errorResponse.ResponseCode'=="AESCEE")) as "AESCEE Count" 
count(eval('errorResponse.ResponseCode'=="AERCEE")) as "AERCEE Count" 
count(eval('errorResponse.ResponseCode'=="CPDNA")) as "CPDNA Count"
count(eval('errorResponse.ResponseCode'=="CPMNF")) as "CPMNF Count"
count(eval('errorResponse.ResponseCode'=="CPLOB")) as "CPLOB Count"
count(eval(isnull('errorResponse.TimeStamp'))) as "Timeout Count"
count(eval('errorResponse.JsonResponse'=="" or isnull('errorResponse.JsonResponse'))) as "Success/No Error Code Count"
by "requestSpecificElements.clientID" "requestSpecificElements.locationID"
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

csharm21
Loves-to-Learn

Thanks @niketnilay this worked for me.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@csharm21

Can you please make sure below points?

1) Check whether all field available... Mainly those which are in by clause.
index=throwaway sourcetype=GIC-EMR-Wrapper-log_V1 | table errorResponse.*
2) Try with Enclosing filed name value with quotes. like count(eval("errorResponse.ResponseCode"="CCEABR")) as "CCEABR Count" &
from requestSpecificElements.clientID to "requestSpecificElements.clientID"

0 Karma

csharm21
Loves-to-Learn

Hi Kamlesh,

Even if i run
index=throwaway sourcetype=GIC-EMR-Wrapper-log_V1 | stats count(eval("errorResponse.ResponseCode"="CCEABR")) as "CCEABR Count"

I get only 0 count

but if i use i get some output like below.
index=throwaway sourcetype=GIC-EMR-Wrapper-log_V1 errorResponse.ResponseCode="*" |stats count by errorResponse.ResponseCode

errorResponse.ResponseCode count
CCEAIT 2
CPLOB 3
null 6

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...