Splunk Search

Extracting Field from 2 different events

ralam
Explorer

Dear All,

I want to extract fields from the below events. The problem I'm facing is that the fields are not in harmony. For example, in event 1, "action" is the second last key however in event 2, it is the last one.

Similarly, some of the fields that are available in event 2, do not exist in event 1.

Can you guide me in extracting the fields from these events?

Event 1

Fri May 08 11:44:37 PDT 2020|{"timestamp":1588963477939,"caller":"xyz@abc","applicationId":null,"applicationName":null,"action":"LOGIN","message":"User [xyz@abc] logged in successfully"}

Event 2

Fri May 08 18:44:38 UTC 2020|{"timestamp":1588963478783,"caller":"xyz@abc","applicationId":20575244,"applicationName":"TIB_TST","entityType":"APPLICATION","entityId":20575244,"entityName":"TIB_TST","changes":[{"property":"name","value":"TIB_TST"}],"action":"OBJECT_CREATED"}
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The fields don't have to be in harmony. You can use multiple rex commands to get each one. For example,

<your search> | rex "action\":\"(?<action>[^\"]+)"
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The fields don't have to be in harmony. You can use multiple rex commands to get each one. For example,

<your search> | rex "action\":\"(?<action>[^\"]+)"
---
If this reply helps you, Karma would be appreciated.

ralam
Explorer

Thank you @richgalloway. I have always believed that the bigger question has always a smaller answer.
Your answer solved my bigger issue. However, one small problem, using your method I extracted many fields but facing a weird issue with "entityId":20575244. I used "entityId\":(?<entityId>\d+)" for it which worked in search but the same failed while applying in the Field Extractor application. It could not match to a single event.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The field extractor may not like the escaped quote.

---
If this reply helps you, Karma would be appreciated.
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!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...