Splunk Search

Need help in extracting branch numbers from event message

labaningombam
Explorer

I have a field called RenderedMessage in event log which has the following text

Task finished:  TaskID 1 for branch 6000

I have been given the task to alert in an email all the branches that has the tasked finished.

In my search, I am able to get the events for this task as

index=prod | spath RenderedMessage | search RenderedMessage="*Task finished: ColleagueNextWeekTask*"

How shall I extract only the branch values from this events/message? I need only the 6000 from this.

Thank you.

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use the rex command to extract a field from another field (including _raw).

| rex field=RenderedMessage "branch (?<branch>\d+)"

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

labaningombam
Explorer

Thank you so much, @richgalloway It works. Is there a way I can display only the branch after this command without showing count. I can display it with

| stats count by branch

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The table command can do that.

| table branch

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use the rex command to extract a field from another field (including _raw).

| rex field=RenderedMessage "branch (?<branch>\d+)"

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...