Splunk Search

How to extract content from field using rex?

ivana27
Path Finder

Dears,

please help. I have log like this 

[Information] PosService AddInfo:[5006] - Stop customer

And i want to show in table message after ":", currently i am using rex like this but i dont have result:

| rex field=_raw "PosService\sAddInfo\:(?<addinfo>\w+|)"

 

Thank you!

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @ivana27,

if the code you need to display is only the code between square parenthesis, you could use a regex like this:

| rex "PosService\s+AddInfo:\[(?<addinfo>\d+)"

as you can see at https://regex101.com/r/dtpR2J/1

If instead you need to display all the message until the end of the row, you have to use the following regex:

| rex "PosService\s+AddInfo:(?<addinfo>.+)"

 as you can see at https://regex101.com/r/dtpR2J/2

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @ivana27,

if the code you need to display is only the code between square parenthesis, you could use a regex like this:

| rex "PosService\s+AddInfo:\[(?<addinfo>\d+)"

as you can see at https://regex101.com/r/dtpR2J/1

If instead you need to display all the message until the end of the row, you have to use the following regex:

| rex "PosService\s+AddInfo:(?<addinfo>.+)"

 as you can see at https://regex101.com/r/dtpR2J/2

Ciao.

Giuseppe

General_Talos
Path Finder

@ivana27 

I hope @gcusello  answer suffice.

If you want to extract after ":" (and considering whatever before ":") you can also use

":\[(?<addinfo>\d+)]"
OR
":(?<addinfo>.+)"

Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...