Splunk Search

extracting log data

kavyatim
Path Finder

Hi,
i have data in following format
PacketPos[503081044] PosInPacket[ 38] NALlength[11634] NAL[98983] Type[Non IDR slice]FrameType[P] DecodingIndex[32207] PresentationIndex[32211] POC[32262] frame_num[83] Structure[TopField] SPSid[0] PPSid[0] PTS[217794471] DTS[217785462]
how will i extract fields and their values using regex. .

Kindly help me in writing regex for this. . .

Thanking in advance,

Tags (1)
0 Karma
1 Solution

gfuente
Motivator

[hide preview] 49 characters / 6 words
Hello

Try using this command:

... | rex "^\w+(?<PacketPos>\[[^\]]+\])\s\w+(?<PosInPacket>\[[^\]]+\])\s\w+(?<NALlength>\[[^\]]+\])\s\w+(?<NAL>\[[^\]]+\])\s\w+(?<Type>\[[^\]]+\])\s?\w+(?<FrameType>\[[^\]]+\])\s\w+(?<DecodingIndex>\[[^\]]+\])\s\w+(?<PresentationIndex>\[[^\]]+\])\s\w+(?<POC>\[[^\]]+\])\s\w+(?<frame_num>\[[^\]]+\])\s\w+(?<Structure>\[[^\]]+\])\s\w+(?<SPSid>\[[^\]]+\])\s\w+(?<PPSid>\[[^\]]+\])\s\w+(?<PTS>\[[^\]]+\])\s\w+(?<DTS>\[[^\]]+\])" |...

Hope it helps

Regards

View solution in original post

gfuente
Motivator

[hide preview] 49 characters / 6 words
Hello

Try using this command:

... | rex "^\w+(?<PacketPos>\[[^\]]+\])\s\w+(?<PosInPacket>\[[^\]]+\])\s\w+(?<NALlength>\[[^\]]+\])\s\w+(?<NAL>\[[^\]]+\])\s\w+(?<Type>\[[^\]]+\])\s?\w+(?<FrameType>\[[^\]]+\])\s\w+(?<DecodingIndex>\[[^\]]+\])\s\w+(?<PresentationIndex>\[[^\]]+\])\s\w+(?<POC>\[[^\]]+\])\s\w+(?<frame_num>\[[^\]]+\])\s\w+(?<Structure>\[[^\]]+\])\s\w+(?<SPSid>\[[^\]]+\])\s\w+(?<PPSid>\[[^\]]+\])\s\w+(?<PTS>\[[^\]]+\])\s\w+(?<DTS>\[[^\]]+\])" |...

Hope it helps

Regards

kavyatim
Path Finder

yes got it. .thank you very much

0 Karma

gfuente
Motivator

Hello you just need to move the brackets outside the capturing group like:

\w+\[(?[^\]]+)\]\s

0 Karma

kavyatim
Path Finder

I mean to say I dont want to extract brackets with values,using above regex I am able to extract values with in brackets. .
how will i extract only values without brackets

0 Karma

kavyatim
Path Finder

i will i extract without [ ] . ..

for example for field Structure, values are [small],[big],[medium]. ..
how to extract without brackets

0 Karma

kavyatim
Path Finder

Thank you very much for your answer i am able to extract . . .

0 Karma

gfuente
Motivator

That regex works for the example you provided. What problem do you have now?

0 Karma

kavyatim
Path Finder

Tried but not able to make out what is missed

0 Karma

gfuente
Motivator

Try again, there were missing backslash

0 Karma

kavyatim
Path Finder

Hi ,

Thank you very for your answer. .
Getting below error ,can you correct the error.
Regex - Cannot find regex reference: ^, in regex: '^w+(?[[^]]+])sw+(?[[^]]+])sw+(?[[^]]+])sw+(?[[^]]+])'

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...