Splunk Search

REGEX to collect all data after final closing bracket

Michael_Schyma1
Contributor

Hey Guys,
Here are a few examples of the logs that we have. I am having trouble grabbing from the last bracket ] to the end in each log file over with a rex.

Thank you

 Aug 28 10:21:26 chtr990.company.com Aug 28 14:21:26 Vpxa: [2012-08-28 14:21:26.151 17CBFB90 verbose 'App'] Set internal stats for VM: 31 (vpxa VM id), 1625 (vpxd VM id). Is FT primary? 0
    Aug 28 10:21:26 chtr990.company.com Aug 28 14:21:26 Vpxa: [2012-08-28 14:21:26.094 17E45B90 verbose 'App'] [VpxaInvtVmChangeListener] Guest DiskInfo Changed
    Aug 28 10:21:26 chtr990.company.com Aug 28 14:21:26 Vpxa: [2012-08-28 14:21:26.094 17E45B90 verbose 'App'] [VpxaHalServices] VmGuestDiskChange Event for vm(203) 3248
    Aug 28 10:21:26 chtr990.company.com Aug 28 14:21:26 Vpxa: [2012-08-28 14:21:26.093 17E45B90 verbose 'App'] [VpxaHalVmHostagent] 3248: GuestInfo changed 'guest.disk'
    Aug 28 10:21:26 chtr990.company.com Aug 28 14:21:26 Vpxa: [2012-08-28 14:21:26.093 17E45B90 verbose 'VpxaHalCnxHostagent'] [VpxaHalCnxHostagent::ProcessUpdate] Applying updates from 3213921 to 3213922 (at 3213921)
Tags (1)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

This ought to work.

... | rex "\]\s(?<msg>.*?)\s*$"

or if that's too greedy, try

... | rex "\]\s(?<msg>[^\]]*?)\s*$"

The new field will be called msg and contain everything from the last ending square bracket to the end-of-line.

/k

View solution in original post

kristian_kolb
Ultra Champion

This ought to work.

... | rex "\]\s(?<msg>.*?)\s*$"

or if that's too greedy, try

... | rex "\]\s(?<msg>[^\]]*?)\s*$"

The new field will be called msg and contain everything from the last ending square bracket to the end-of-line.

/k

kristian_kolb
Ultra Champion

updated with a less greedy variant /k

0 Karma

Michael_Schyma1
Contributor

Any suggestions???

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...

[Puzzles] Solve, Learn, Repeat: Dereferencing XML to Fixed-length events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...