Splunk Search

How to extract container name and ID from a log using regex?

pavanmishra0102
Engager

(Item Id: 45) Container Name: Abc Admin Accounts (Container Id: 19) suid=1

need to extract Container name & Container id from the above partial log posted here using regex. Kindly help. Thanks in advance

Labels (1)
0 Karma
1 Solution

rnowitzki
Builder

Hi @pavanmishra0102 ,

This should do it:

Container\sName:\s(?<container_name>.*)\((?<=\()Container\sId:\s(?<container_id>\d+)\)


BR
Ralph
--
Karma and/or Solution tagging appreciated.

--
Karma and/or Solution tagging appreciated.

View solution in original post

rnowitzki
Builder

Hi @pavanmishra0102 ,

This should do it:

Container\sName:\s(?<container_name>.*)\((?<=\()Container\sId:\s(?<container_id>\d+)\)


BR
Ralph
--
Karma and/or Solution tagging appreciated.

--
Karma and/or Solution tagging appreciated.

isoutamo
SplunkTrust
SplunkTrust

Hi

this helps you:

index=_internal
| head 1
| eval _raw ="(Item Id: 45) Container Name: Abc Admin Accounts (Container Id: 19) suid=1"
| rename COMMENT "Previous sets sample data, next line select values"
| rex "Container Name: (?<CName>[^\(]+)\(Container Id: (?<CId>\d+)"

r. Ismo 

Get Updates on the Splunk Community!

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2025 SplunkTrust is officially open! If you ...

Splunk Answers Content Calendar, June Edition II

Get ready to dive into Splunk Dashboard panels this week! We'll be tackling common questions around ...

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...