Splunk Search

i want to remove all the word starts with OBJ and till 1-3453221. the number will be dynamic and constant in length . we need to remove from string based on OBJ with length

DataOrg
Builder

this is word obj:1-324dfs32 hello world obj:1-3453221 as a god

0 Karma
1 Solution

Richfez
SplunkTrust
SplunkTrust

Using "obj:1-324dfs32 hello world obj:1-3453221 as a god"

| rex mode=sed "s/obj\S+//g" 

Should trim it to "hello world as a god"

The formatting of your example could be better, but that's probably the key thing above. It says to 's' substitute, whenever you find '/obj\S+' or the string "obj" followed by non-spaces, instead insert the characters "nothing" (there's nothing between the two // slashes for the substitution, globally /g (do it multiple times in one string, don't just do it the first time it sees it and stops).

View solution in original post

Richfez
SplunkTrust
SplunkTrust

Using "obj:1-324dfs32 hello world obj:1-3453221 as a god"

| rex mode=sed "s/obj\S+//g" 

Should trim it to "hello world as a god"

The formatting of your example could be better, but that's probably the key thing above. It says to 's' substitute, whenever you find '/obj\S+' or the string "obj" followed by non-spaces, instead insert the characters "nothing" (there's nothing between the two // slashes for the substitution, globally /g (do it multiple times in one string, don't just do it the first time it sees it and stops).

DataOrg
Builder

it worked but it is timing other fields. i want it to cut with length only obj:1-3453221

0 Karma

Richfez
SplunkTrust
SplunkTrust

Sure, so you want to trim just that many characters -

| rex mode=sed "s/obj.{10}//g" 

That says to find the string "obj" followed by precisely {10} of any character (. ) Obviously change the 10 to whatever you need, but I think it's about right.

If that's not quite right, can you provide a few more examples and exactly what you need each example to have as its output?

0 Karma

DataOrg
Builder

thanks. it's worked. 🙂

0 Karma

DataOrg
Builder

otherwise we can cut with first space as space delimiter

0 Karma

Richfez
SplunkTrust
SplunkTrust

My original answer does cut to the first space. Can you give more specifics about what it does wrong?

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...