Splunk Search

How to Extract Values from a KV within a event log

vickyvishwa
Explorer

I have the below log event.

[INFO ] 2019-01-24T04:09:20,513 [thread=framework1234] className=DummyConsumer - {} - {topic=events-1, timestamp=12233344433, timestampType=CREATE_TIME, value={msg_id=bdb95851-1fd0-11e9-a1b3-yhgt6465783gh, ip=127.0.0.1, timestamp=2019-01-24 04:08:50.0}, logMessage=Event Processed, failure=F}

I have to extract timestamp and ip both of them inside value key. What is the best way to do that. I tried multiple extract commands nothing works (or probably I am doing wrong).

Tags (1)
0 Karma
1 Solution

harsmarvania57
Ultra Champion

Hi,

Please try below regex, this will extract values in two fields timestamp and ip

<yourBasesearch> | rex field=_raw "ip=(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\,\stimestamp=(?<timestamp>[^}]*)"

View solution in original post

0 Karma

vnravikumar
Champion

Hi @vickyvishwa

Please Try

| makeresults 
| eval log=" [INFO ] 2019-01-24T04:09:20,513 [thread=framework1234] className=DummyConsumer - {} - {topic=events-1, timestamp=12233344433, timestampType=CREATE_TIME, value={msg_id=bdb95851-1fd0-11e9-a1b3-yhgt6465783gh, ip=127.0.0.1, timestamp=2019-01-24 04:08:50.0}, logMessage=Event Processed, failure=F}" 
| rex field=log "ip=(?P<ip>.*),\stimestamp=(?P<timestamp>.*)}," 
| table ip,timestamp
0 Karma

harsmarvania57
Ultra Champion

Hi,

Please try below regex, this will extract values in two fields timestamp and ip

<yourBasesearch> | rex field=_raw "ip=(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\,\stimestamp=(?<timestamp>[^}]*)"
0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...