Getting Data In

How do you extract fields from JSON logs?

moizmmz
Path Finder

Hello,

I have the following JSON log event:

{   [-] 
     line:   I 1019 15:40:22.873 UTC THREAD1: **linkerd 1.4.5** (rev=0280009ca71e0673108a3752763938017bda588f) built at 20180713-154546 
     source:     stderr 
     tag:    linkerd/e03c11099322   
}

I want to extract the version of Linkerd given in this log. i.e., I want the following result: Field name: Linkerd version; value: 1.4.5

Pls help!!

Tags (2)
0 Karma
1 Solution

493669
Super Champion

try this regex to extract linkerd version-

   ... |rex "linkerd\s(?<linkerd_version>[^\s]+)" 

View solution in original post

0 Karma

493669
Super Champion

try this regex to extract linkerd version-

   ... |rex "linkerd\s(?<linkerd_version>[^\s]+)" 
0 Karma

moizmmz
Path Finder

Excellent! It gives me exactly what i want! Thank you so so much!!

Can you please tell me how you wrote this?

0 Karma

493669
Super Champion

Here rex command is used to extract field values
Explanation:
linkerd\s here \s indicates space so it will find word-linkerd in raw events
[^\s]+ It will check after linkerd\s until it will find any space
(?<linkerd_version> then it will store extracted value in field name linkerd_version

0 Karma

moizmmz
Path Finder

Thank you thank you thank you!!!!!!

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 ...