Splunk Search

How to extract logs by rex ?

karthi2809
Contributor

How to extract logs by rex ?
"TranStartTime":"2017-05-08T02:40:58.856-04:00", "TranEndTime":"2017-05-08T02:40:58.902-04:00"

need to TranStartTime and TranEndTime

Tags (1)
0 Karma

cpetterborg
SplunkTrust
SplunkTrust

Try this:

_your_search_ | rex "\"TranStartTime\":\"(?P<tranStartTime>[^\"]*)\",\s\"TranEndTime\":\"(?P<tranEndTime>[^\"]*)\""

DalJeanis
SplunkTrust
SplunkTrust

I'd probably put them in two separate rexes, just in case they ever arrived in a different order or separated by something else. Upvoted anyway, it works per regex101.com.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...