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!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...