Splunk Search

how to extract data after a colon

joyce1018
New Member

example

[dto=forename: "abcforename"
surname: "abcsurname" ..................]

I want to extract the forename and surname ,
and let them combine as a field USER

how?

MANY THX.

0 Karma
1 Solution

ramdaspr
Contributor

You would have to tune the regex to match your requirement but the query would be somewhat like below

.. | rex field=fieldnamehere "dto\=forename\:\s\"(?<fname>\w+)\"\ssurname\:\s\"(?<sname>\w+)\"" | eval merged=fname." ".sname

View solution in original post

ramdaspr
Contributor

You would have to tune the regex to match your requirement but the query would be somewhat like below

.. | rex field=fieldnamehere "dto\=forename\:\s\"(?<fname>\w+)\"\ssurname\:\s\"(?<sname>\w+)\"" | eval merged=fname." ".sname

esix_splunk
Splunk Employee
Splunk Employee

Use a multiline rex.. This will capture everything in the "..".

search.... | rex field=_raw "^\[dto=forename\:\s\"(?<fname>.*)\"\nsurname\:\s\"(?<lastname>.*)\"" | table forename lastname

Another option would be to use props, set your sourcetype with linemerge=false, and define your event boundaries.

0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...