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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...