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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...