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 Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...