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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...