2

I have a log event getting in a json format like this

{
   "level":"level  name",
   "exception":"exception message",
   "logger":"com.log",
   "thread":"thread name",
   "message":"exception message",
   "properties":{
      "id":"1234",
      "process":"Process name,
      "host":"host name",
      "type":"type name"
   }
}

I need a splunk query to get host inside properties as a value to get it in a table. Please help me.

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
kenz
  • 112
  • 12

2 Answers2

1

What have you tried already?

I suspect this (or similar) will work, presuming Splunk's identified this data as being in JSON format already:

index=ndx sourcetype=srctp properties{}.host=*
| rename properties{}.host as hostname
| stats count by hostname
warren
  • 32,620
  • 21
  • 85
  • 124
0

It would help to see what you've tried already so we don't suggest something that doesn't work.
There probably are a few ways to do that, but here's one of them.

... | rex "host\":\"(?<hostName>[^\"]+)"
| table hostName

Note I specifically did not call the field "host" to avoid conflict with the built-in field of the same name.

RichG
  • 9,063
  • 2
  • 18
  • 29