Splunk Search

Groupby on a name-value pair within a field

skpatnaik
New Member

I have an oracle log file (i am pasting below one record from the log file)
I intend to a table with all possible RETURNCODE[1] values (group by on the name-value pair within the field Message) alongwith their respective count. Please help with a splunk search string

---------- 1 Record From The Log File---------------
8:09:00.000 PM

LogName=Application
SourceName=Oracle.orcl
EventCode=34
EventType=4
Type=Information
ComputerName=Linus-PC
TaskCategory=None
OpCode=None
RecordNumber=2144220
Keywords=Classic
Message=Audit trail: LENGTH: "385" SESSIONID:[6] "101355" ENTRYID:[1] "1" STATEMENT:[1] "1" USERID:[6] "DBSNMP" USERHOST:[18] "WORKGROUP\LINUS-PC" TERMINAL:[8] "LINUS-PC" ACTION:[3] "100" RETURNCODE:[1] "0" COMMENT$TEXT:[114] "Authenticated by: DATABASE; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=fe80::5d33:f1be:ba6:dda3%11)(PORT=20072))" OS$USERID:[19] "NT AUTHORITY\SYSTEM" DBID:[10] "1343606950" PRIV$USED:[1] "5".

Tags (1)
0 Karma

lguinn2
Legend

Try this

yoursearchhere
| rex field=Message "RETURNCODE:\[1\]\s\"(?<return_code>.*?)\""
| stats count by return_code

I don't know what search you need for the initial data retrieval, but source=*thefilename.ext" might work.

kristian_kolb
Ultra Champion

That's a Windows Event Log, so source=WinEventLog:Application SourceName=oracle.orcl would probably work better.

0 Karma
Get Updates on the Splunk Community!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...