Splunk Search

Rex to get data between curly brackets

bsaujla131984
Path Finder

I am struggling to fetch the data between curly brackets . Have tried multiple rex searches, however still not getting the required output :-

Message in log is as below:

msg=Call to https://hostname/rs/cf/webservice/user/authn failed. Status code: 401, response: {"statusCode":"Code","message":"Authentication failed"}|exception=|

I want to everything after response till exception.

Can anyone help with this please?

Labels (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

... | rex "(?ms)response:\s*(?<MyNewField>\{[^\}]+\})"

View solution in original post

woodcock
Esteemed Legend

Like this:

... | rex "(?ms)response:\s*(?<MyNewField>\{[^\}]+\})"

bsaujla131984
Path Finder

Thanks Woodock. This was really quick response.

May I know the purpose of (?ms) ?

woodcock
Esteemed Legend

In case your raw event data is multi-line. You probably do not need it.

Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...