Splunk Search

How to write a Field Extraction using PROPS Configuration File for Nested JSON Events?

SplunkDash
Motivator

Hello,

I have done field extraction for the nested JSON event using props.conf file.  Everything is working as expected but facing one issue based on my requitements. Sample JSON event, my props.conf file, and the reequipments/issue are giving below.  Any help will be greatly appreciated, thank you so much.

Sample Nested JSON Event:

{"TIME":"20220622154541","USERTYPE":"DSTEST","UID":"TEST01","FCODE":"06578","FTYPE":"01","SRCODE":"0A1","ID":"v23488d96-a1283-4ddf-8db7-8911-DS","IPADDR":"70.215.72.231","SYSTEM":"DS","EID":"ASW-CHECK","ETYPE":"VALID","RCODE":"001","DETAILINFO":{"Number":"03d1194292","DeptName":"DEALLE","PType":"TRI"},"YCODE":"1204342"}

 props.conf:

[sourcetypename]

CHARSET=UTF-8

EVENT_BREAKER_ENABLE=TRUE

INDEXED_EXTRACTIONS=json

KV_MODE=json

LINE_BREAKER=([\r\n]+)

MAX_TIMESTAMP_LOOKAHEAD=30

NO_BINARY_CHECK=true

SHOULD_LINEMERGE=true

TIME_FORMAT=%Y%m%d%H%M%S

TIME_PREFIX={"TIME":"

TRUNCATE=2000

category=Custom

disabled=false

pulldown_type=true

 

Issue/Requirements:

I am getting Key/Value pair for the nested Key/Field DETAILINFO as

DETAILINFO.Number = 03d1194292

DETAILINFO.DeptName = DEALLE

DETAILINFO.PType = TRI

My requirement:  "DETAILINFO" Key/Value pair should show up like below after the extraction:

DETAILINFO ="Number":"03d1194292","Dept name":"DEALLE","PType":"TRI"

OR

DETAILINFO= {"Number":"03d1194292","Dept name":"DEALLE","PType":"TRI"}

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

I don't think that's possible at index time.  Use spath at search time

 

| spath path=DETAILINFO

 

Or use json_extract()

 

| eval DETAILINFO = json_extract(_raw, "DETAILINFO")

 

 

Tags (2)

SplunkDash
Motivator

Hello,

Thank you so much for your reply. But how can I use it in my props.conf file?

0 Karma

yuanliu
SplunkTrust
SplunkTrust

You cannot.  Potentially you can set this up as an extracted field so you don't have to enter it in search line

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 ...