Splunk Search

How to preventy hyphens in fieldnames with KV_MODE JSON?

jbrocks
Communicator

Hi everybody,

I am extracting nested JSON with KV_MODE = JSON, which seems to work correctly.
My problem is, I am getting field names with hyphens in it (like in the raw event) e.g. "alert.expl.cnc-services.cnc-service.sid". First of all, is there any possibility of key cleaning while using KV_MODE = JSON extraction? For example I am not able to use the extracted field above in coalesce function because of the hyphen. Can anybody help me?

0 Karma

woodcock
Esteemed Legend

You cannot prevent it without doing your own manual field extraction but what you can do is remove/replace them at the beginning of your search by doing something like this (which would best be done inside a macro called dash2underscore)

.... | rename *-*-*-*-*-* AS *_*_*_*_*_*, *-*-*-*-* AS *_*_*_*_*, *-*-*-* AS *_*_*_*, *-*-* AS *_*_*, *-* AS *_*
0 Karma

codebuilder
Influencer

You can use a combination of props.conf and transforms.conf to replace the dash "-" with the symbol of your choice.
Within transforms.conf, set DEST_KEY = _raw.

Note that this method requires a HF and would take effect on newly indexed data only (it would not be retroactive).

----
An upvote would be appreciated and Accept Solution if it helps!
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 ...