Splunk Enterprise

Remove spaces from all field names

aa70627
Communicator

Is there any quick way to remove specific at the beginning and end of all fields names? For example i am looking looking to remove all spaces to the left and right of all field names. How do i do this?

0 Karma

ifathklein
Engager

foreach * [ eval newFieldName=replace("<<FIELD>>", "\s+", "_"),  {newFieldName}='<<FIELD>>'  ] | fields - "* *", newFieldName

romedome
Path Finder

Very smart! Thanks!

0 Karma

niketn
Legend

@aa70627, you are possibly looking for the trim() evaluation function. You can also use replace() evaluation function to replace regular expression based match pattern from string.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

xpac
SplunkTrust
SplunkTrust

Can you show an example of what you have right now, and how you would like it to be?

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...