Getting Data In

How to extract fields without a name from a JSON event?

dannili
Communicator

Hi all, I'm using virtual index to access log files stored in Hadoop and then trying to extract certain values from JSON formatted file. But the the parsed file does not have name but only string values enclosed in ""with comma between them so the rex wouldn't work. So I was wondering if there's any possible solution to extract these. here's one example:(For example I'm extracting two email address)

11:14:45.000 AM "admin0f.online.lync.com","073e10cd-3910-46d9-95ee-e72ff0ed41dc","False","f24484cef680422ca872a99e47986e5d;add34fecd1;44a0bc0b3e","","7/13/2018 9:34:52 AM","7/13/2018 9:36:44 AM","jessica@example.com","alex@example.com","UCCAPI/16.0.9330.2118 OC/16.0.9330.2118 (Skype for Business)","UCCAPI/16.0.9330.2118 OC/16.0.9330.2118 (Skype for Business)","","","34872F8C-DBB6-53AD-8815-9328990D7FB8","B4DD4A65-1BFA-5E22-9194-F8D06EA27D9F","","","","","200","[IM]","{""RequestType"":""BYE"",""RequestTime"":""2018-07-13T09:36:44.016"",""ContentType"":""application/sdp;call-type=im"",""ResponseCode"":"""",""DiagnosticId"":51004,""ErrorCategory"":""Success"",""DiagnosticHeader"":""51004; reason=\""Action initiated by user\"";\""OriginalPresenceState=\""\""3000\""\"";CurrentPresenceState=\""\""3000\""\"";MeInsideUser=\""\""No\""\"";ConversationInitiatedBy=\""\""6\""\"";SourceNetwork=\""\""2\""\"";RemotePartyCanDoIM=\""\""Yes\""\""\""""} {""RequestType"":""BYE"",""RequestTime"":""2018-07-13T09:36:43.5572341"",""ContentType"":"""",""ResponseCode"":""200"",""DiagnosticId"":51004,""ErrorCategory"":""Success"",""DiagnosticHeader"":""51004; reason=\""Action initiated by user\""""}
0 Karma
1 Solution

acharlieh
Influencer

That event is not JSON ... it's a CSV, where one field happens to be JSON encoded within it. You should look into defining a sourcetype, that defines extractions based on delimiters.

You can use the field extractor to help you with this definition:
http://docs.splunk.com/Documentation/Splunk/7.1.2/Knowledge/FXSelectMethodstep
http://docs.splunk.com/Documentation/Splunk/7.1.2/Knowledge/FXRenameFieldsstep

Alternatively you could use regular expressions to skip through a certain number of groups of (Not comma, comma) until you come to your email addresses that you want to extract, but that seems more tedious.

View solution in original post

acharlieh
Influencer

That event is not JSON ... it's a CSV, where one field happens to be JSON encoded within it. You should look into defining a sourcetype, that defines extractions based on delimiters.

You can use the field extractor to help you with this definition:
http://docs.splunk.com/Documentation/Splunk/7.1.2/Knowledge/FXSelectMethodstep
http://docs.splunk.com/Documentation/Splunk/7.1.2/Knowledge/FXRenameFieldsstep

Alternatively you could use regular expressions to skip through a certain number of groups of (Not comma, comma) until you come to your email addresses that you want to extract, but that seems more tedious.

dannili
Communicator

btw there's a typo in question... I meant exactly the regular expression, that is, rex.

0 Karma

dannili
Communicator

Yes you are right.. I totally misinterpreted it. Thanks a lot!

0 Karma
Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...