Splunk Search

Is it possible to remove a string from _raw in a search using wildcards with the replace command?

rlough
Path Finder

Hello,

I'm trying to remove a string from the _raw of my search with the replace command and was wondering if wildcards are available.

My data looks something like: BlahBlah M4550GImportantStuffi
I'm trying to replace "M4550G" with the empty string.

Is this possible? The string "M4550G" can have any numbers but the M and G will always be there.

Tags (3)
1 Solution

chanfoli
Builder

I am not sure that replace could do this well given that we are talking about scanning the entire raw event. You could however use rex in sed mode to replace the string at search time, you could also use a sed transform at index time which might help search performance if your _raw fields are large and you notice a performance impact:

[your search] | rex field=_raw mode=sed "s/M4450G//g"

View solution in original post

chanfoli
Builder

I am not sure that replace could do this well given that we are talking about scanning the entire raw event. You could however use rex in sed mode to replace the string at search time, you could also use a sed transform at index time which might help search performance if your _raw fields are large and you notice a performance impact:

[your search] | rex field=_raw mode=sed "s/M4450G//g"
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...