Splunk Search

Need a regex that extracts a string from event plus 6 characters after

Bleepie
Communicator

Dear Splunk Community,

I need help extracting a string (CTJT) plus any 6 characters after. CTJT is the start of an error code and always the same, the 6 characters after are different but always 6 charaters. Meaning the full error code is 10 characters like this: CTJTAAB013

The error codes in the events are always on random positions, never fixed!

I need to extract the errorcode and evaluate it in a field:

 

CTJT*
| table errorcode
| eval errorcode = "I want to fetch the error code here"

 

 

I have tried substr but I cant find a method for fetching the first index of CTJT. Can anyone help me create a regex that does the above or maybe some other way?

 

Thanks in advance

Labels (5)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<errorcode>CTJT\w{6})"

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "CTJT(?<errorcode>\w{6})"
0 Karma

Bleepie
Communicator

Hello IT Whisper, any idea on why no results are show even though there are 569 statistics show? When clicking on events I can see all events.

Bleepie_0-1632480823318.png

 

Tags (1)
0 Karma

Bleepie
Communicator

Little edit:

When I include _raw in the table I can see the following:

Bleepie_0-1632481104908.png

 

But its missing CTJT in front of it.

 

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<errorcode>CTJT\w{6})"
0 Karma

Bleepie
Communicator

Thanks a lot sensei!

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...