Splunk Search

How can I remove excess characters from my fields?

AKG1_old1
Builder

Hi,

In my log file one field called Script Name contains some unnecessary details, which I want to remove.

My requirement is to remove "qcst_" ".sh" and all others arguments like "-LS" "/hp267srv/apps/MXTEST" etc

Actual Data:

qcst_mxStEnvLoad.sh
qcst_ZipLastRun.sh Order_Simulation /hp267srv/apps/MXTEST /net/hp267srv/hp267srv/apps/MXTEST Order_Simulation
qcst_runningProcessesDetails.sh -LS

Expected:

mxStEnvLoad
ZipLastRun
runningProcessesDetails

Thanks
Ankit

0 Karma
1 Solution

sbbadri
Motivator

try this

.... | rex field=_raw "qcst_(?P<field1>\S+).sh"

View solution in original post

alemarzu
Motivator

Hi there @agoyal

Assuming that you already have a field that contains those values (ie, command) you can create a new field from it with the new values, like this.

base search | rex field="command" "^\S+_(?<trimmed_command>[^\.]+)\.\S+"

Hope it helps.

sbbadri
Motivator

try this

.... | rex field=_raw "qcst_(?P<field1>\S+).sh"

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 ...