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