Splunk Search

timechart count by -not a legit field-

mitcanmit
Explorer

Hi,

I want to show the stats based on the different values of the "state" field. "timechart count by result" does not work -probably because the format is not json and splunk fails to understand that "state" is a field. How do I handle this? I have tried rex function but did not manage to get the results I need.

I am trying to get something like this:
success=1231
aborted=322
pending=111

Thanks in advance for the help.

HTTP ***
Headers: [{'Cache-Control',"max-age=0, no-cache"},
          {'Content-Length',"400"},
          {'Content-Type',"application/json;charset=utf-8"},
          {'Host',"***"},
          {'Pragma',"no-cache"},
          {'X-Forwarded-For',"***"}]
Body: [{amount,***},
       {client_reference,"***"},
       {connector,"**"},
       {connector_reference,"***"},
       {consumer_save_card,false},
       {credit_card,[{brand,"***"},
                     {card_number,"**"},
                     {exp_month,***},
                     {exp_year,***},
                     {holder,"***"},
                     {type,"***"}]},
       {currency,"***"},
       {gateway_reference,"***"},
       {state,"success"}]
Tags (1)
0 Karma
1 Solution

tpflicke
Path Finder

The following should do the trick though producing the regular stats output format:

... | rex field=_raw "\{state,\"(?<state>\w*)" | stats count by state | sort -count

or with timechart:

... | rex field=_raw "\{state,\"(?<state>\w*)" | timechart count by state

View solution in original post

tpflicke
Path Finder

The following should do the trick though producing the regular stats output format:

... | rex field=_raw "\{state,\"(?<state>\w*)" | stats count by state | sort -count

or with timechart:

... | rex field=_raw "\{state,\"(?<state>\w*)" | timechart count by state

mitcanmit
Explorer

Thanks a lot!

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...