Splunk Search

Extract Json Fields

srikanthr123
Explorer

We want to extract Json key&Value pairs, but source is prefixing the text before Json data.
Please let us know the search string to extract json fields.

*************************************
2020-06-22 23:52:40,895 INFO [Timer-Driven Process Thread-10] o.a.nifi.processors.standard.LogMessage LogMessage[id=2202601e] TEST{
"domain": "ABC",
"module": "TEST",
"EventID" : "1233"
}

Labels (1)
0 Karma
1 Solution

to4kawa
Ultra Champion
| makeresults
| eval _raw="2020-06-22 23:52:40,895 INFO [Timer-Driven Process Thread-10] o.a.nifi.processors.standard.LogMessage LogMessage[id=2202601e] TEST{
\"domain\": \"ABC\",
\"module\": \"TEST\",
\"EventID\" : \"1233\"
}"
| rex "(?ms)(?<json>{.*})"
| spath input=json


Is there a reason why you don't do as I said?

View solution in original post

to4kawa
Ultra Champion

try rex and spath input=rex_field

0 Karma

srikanthr123
Explorer

I tried something like this but it is not working. can you please share the correct string

rex field=_raw "eventId=\"(?<eventId>.*)\"" | spath output=OpName path="eventId"

 

0 Karma

to4kawa
Ultra Champion
| makeresults
| eval _raw="2020-06-22 23:52:40,895 INFO [Timer-Driven Process Thread-10] o.a.nifi.processors.standard.LogMessage LogMessage[id=2202601e] TEST{
\"domain\": \"ABC\",
\"module\": \"TEST\",
\"EventID\" : \"1233\"
}"
| rex "(?ms)(?<json>{.*})"
| spath input=json


Is there a reason why you don't do as I said?

srikanthr123
Explorer

can you please share the rex command to extract the fields

0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...