Splunk Search

Key value pair extraction

SrinivasaC
Path Finder

My Sample data is below:

2017-07-17 23:59:43,156 ERROR------------webserver logs from servers------------ Attributes Key: 'Date' Value: 'Mon Jul 17 23:56:36 EDT 2017' Key: 'Size' Value: '597' Key: 'Attribute' Value: 'unmatched' Key: 'Content' Value: 'http' Key: 'timestamp' Value: '1500350196677' Key: 'origin' Value: 'TEST' Key: 'event_timestamp' Value: '2017-52-78 14:17:39.364' Key: 'file' Value: '1083753866763157' Key: 'tokenid' Value: '0e85b547' Key: 'offset' Value: '112' Key: 'partition' Value: '2' Key: 'topic' Value: 'DEV12345' Key: 'path' Value: './' Key: 'idms' Value: '8339e9de-a743-4534-b346-d5a06ea39b21' ------------

Here I want
Date= Mon Jul 17 23:56:36 EDT 2017
size = 597
Attribute = unmatched
Content = http
.. etc

| rex ".*Key:\s\'(?P[^']+)\'\sValue:\s\'(?P[^']+)\'\s+"

tried the extraction but here myKey1 , myValue nothing is extracted.
Also tried some extract command for pairdelim and kvdelim attributes.. no luck.
Any help here will be most helpful.

Thanks in advance 🙂

0 Karma

sbbadri
Motivator

try below

your base search | rex field=test max_match=100 "Key:\s\'(?P<key>\w+)\'\s+Value:\s+\'(?P<Value>\S+)\'" | table test key Value

0 Karma

SrinivasaC
Path Finder

Its not giving me exact results.. Its showing result as Values(key1) and values(value1) result. These fields are not showing in interested fields. Thanks for your quick help

Output im getting below:
test Key1 value1
test1 Date Mon Jul 17 23:56:36 EDT 2017
\t size 597
\tAttribute unmatched
\tContent http
test2 Date Mon Jul 17 23:56:36 EDT 2017
\tsize 597
\tAttribute unmatched
\tContent http

0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...