Getting Data In

JSON/Syslog and SPATH

matthewparry
Path Finder

Hi,

I have JSON data being indexed from a syslog file i.e

Nov  2 23:04:47 host1 /usr/local/bin/audit.rb[24503]: { "@fields" : {  "action" : "check", "agent" : "server", "caller" : "user", "callerhost" : "system", "data" : "{:process_results=>true}", "request_time" : 1351746758, "uniqid" : "73670e799fbf576b9225278cc46709c0" }, "@message" : "message", "@source" : "audit", "@source_host" : "host", "@tags" : [  ], "@timestamp" : "2012-11-01T05:12:38.169418Z", "@type" : "audit" }

The problem is I cannot use spath to extract fields, i.e

 | spath output=action path=@fields.action

If I remove the syslog section and only index the JSON data then it works without problems, i.e if the data is just.

{ "@fields" : {  "action" : "check", "agent" : "server", "caller" : "user", "callerhost" : "system", "data" : "{:process_results=>true}", "request_time" : 1351746758, "uniqid" : "73670e799fbf576b9225278cc46709c0" }, "@message" : "message", "@source" : "audit", "@source_host" : "host", "@tags" : [  ], "@timestamp" : "2012-11-01T05:12:38.169418Z", "@type" : "audit" }

Is this normal behaviour, is there a way around it whilst still being able to use the spath function?

Thanks.

Tags (3)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

this is normal. spath operates on either XML or JSON, and with the extra info, your data is not JSON. You can simply use eval prior to using spath to strip out the syslog info prior to piping to spath.

View solution in original post

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

this is normal. spath operates on either XML or JSON, and with the extra info, your data is not JSON. You can simply use eval prior to using spath to strip out the syslog info prior to piping to spath.

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