Splunk Search

Can you help me create a pie chart that would display info from a CSV Lookup file?

sandeepmakkena
Contributor

I created a .CSV file with error_code and Description. I am trying to compare error_code with the logs and create a pie chat that shows all the error descriptions. I tried ...

Index=my_index | [|inputlookup error.csv | fields error_code | rename error_code as query]

... it seems to find the right logs but, it’s not a giving stats count by error_code.
Thanks!

0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@sandeepmakkena

Can you please try following search?

Index=my_index | rex field=_raw "errorCode\\\\\":\\\\\"(?<error_code>\d+)\\\\\"" | lookup error.csv error_code OUTPUT description | stats count by description

My Sample Search:

| makeresults 
| eval _raw="000xxxx XXXXX log Call failed for endpoint XXXX after 703 milliseconds with message {\"requestingSystemId\":\"System1\",\"externalReferenceId\":\"xxx123xxx\",\"responseCode\":\"GROUP_FAILURE\",\"responseDescription\":\"Accounting instruction rejected as processing of one or more accounting entries was unsuccessful\",\"entries\":[{\"externalReferenceId\":\"System1/TransactionId/1/2\",\"responseCode\":\"ACCOUNT_LOCKED\",\"responseDescription\":\"40070,400,AccountOptedOutException: \",\"processingStatusCode\":\"REJECTED\",\"accountBalance\":{\"updateAmountDateTime\":\"Date.000+0000\",\"accountBalance\":0,\"availableBalance\":0,\"source\":\"CACHE\"},\"adapterDescription\":\"adapter1\",\"destinationAccountId\":\"xxxx....xxxx\",\"destinationAccountIdType\":\"yyyx\",\"supplementaryData\":\"{\\\"developerMessage\\\":\\\"AccountOptedOutException: \\\",\\\"errorCode\\\":\\\"40070\\\",\\\"gatewayErrors\\\":[{\\\"code\\\":\\\"40070\\\",\\\"gatewayName\\\":\\\"optout\\\",\\\"operation\\\":\\\"abc.gateway.optout\\\"}],\\\"httpStatus\\\":400,\\\"userMessage\\\":\\\"This account is opted out\\\",\\\"validationErrors\\\"::[]}\",\"errors\":[]}]} [accounting:50] [PaymentInterchange=123456789, PaymentInstruction=678912345, PaymentTransaction=14000xxx34, OPIC=null, RunId=null, uuid=null, origin=InterchangeLoaderMDBBean]" | rex field=_raw "errorCode\\\\\":\\\\\"(?<error_code>\d+)\\\\\"" | lookup error.csv error_code OUTPUT description | stats count by description

Updated Answer:

index=my_index | rex field=_raw max_match=0 "errorCode\\\\\":\\\\\"(?<error_code>\d+)\\\\\"" 
| rex field=_raw max_match=0 "responseCode\":\"(?<response_code>\w+)" 
| eval error_code = if(isnotnull(error_code) AND error_code!="", error_code,response_code) 
| table error_code | lookup error.csv error_code OUTPUT description | stats count by description

Thanks

View solution in original post

0 Karma

Vijeta
Influencer

index=my_index| fields error_code| join error_code[|inputlookup error.csv| fields error_code , Description]| stats count by Description

0 Karma

sandeepmakkena
Contributor

I tried that it’s not getting me any results. If this helps There is no error_code field extracted from the _raw events.

0 Karma

Vijeta
Influencer

You dont have the error code parsed in your raw events? Can you extract the error code field using regex from raw events?

0 Karma

sandeepmakkena
Contributor

Thanks for the reply Vijeta, my ErrorCode looks like this \”errorCode\”:\”40025\”, I have hard time in getting regex working and also some of logs does not log errors codes but, just description. So the idea is list all those ErrorCode and error description into a lookup file, match with the log data and display on a dashboard with the count.

0 Karma

sandeepmakkena
Contributor

I am using this Rex “errorCode.*(?)” but it’ is not giving anything.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...