Splunk Search

Amending certain characters for values in an extracted field

ajm33
Engager

I'm currently trying to join two log events across separate sources using their file name. The issue i have run in to is that within one log set the spaces in file names are replaced by underscores (for instance "abcd efg.csv" becomes "abcd_efg.csv") whereas the other source maintained the spaces ("abcd efg.csv" remains "abcd efg.csv").

As a result i'm not able to join on the filename. Can anyone help is an expression that would edit the values for the filename field. I'm thinking some kind of eval that replaces any spaces it finds with underscores, however i've not come across away to do this.

Your assistance would be much appreciated.

** Issue resolved using replace **

| rex "(?i)\/xyz\/\w+\/(?P.+).(csv|xls)" | eval FileNameNoSpaces = replace(FileName,"\s","_")

FileNameNoSpaces can then be used to join effectively.

Tags (3)
0 Karma

ajm33
Engager

Issue resolved using replace
| rex "(?i)/xyz/w+/(?P.+).(csv|xls)" | eval FileNameNoSpaces = replace(FileName,"s","_")

FileNameNoSpaces can then be used to join effectively.

0 Karma

matthieu_araman
Communicator

Hello,

you could try something like that | rex field=_raw mode=sed "s/\s/_/g"
replace field=_raw with field=yourownfield to avoir replacing space everywhere
you could also add a form more specific in the sed expression or just keep it simple.

0 Karma

MuS
Legend

Hi ajm33,

take a look at this answer to get an idea to do this without join http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-joi...

The Answer lists sourcetypebut you can do the same over multiple sources.
If this is not possible for your use case, provide some sample events and search you used.

cheers, MuS

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...