Splunk Search

Key-value pair extraction -- regex help

koshyk
Super Champion

We have some snmp data and want to extract the data as a key-value pair

Sample

var.12345.5.5 = INTEGER: 10 myTag::var.12345.5.9 = STRING: "abc"    myTag::var.12345.5.3 = STRING: "admin"  myTag::var.12345.5.4 = STRING: "developer"
var.12345.5.5 = INTEGER: 10 myTag::var.12345.5.9 = STRING: "xyz"    myTag::var.12345.5.3 = STRING: "user1"  myTag::var.12345.5.4 = STRING: "support"

output required

var_12345_5_9,var_12345_5_3,var_12345_5_4
abc,admin,developer
xyz,user1,support

I tried a basic

REGEX=var\.([^ ]+)\s=\s(\S+)
FORMAT = $1::$2
CLEAN_KEYS = true

But can you please help in making it a bit more better?

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try this

REGEX=(var\S+)\s+=\s+[^\"]+([^\"]+)
FORMAT = $1::$2
CLEAN_KEYS = true

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Try this

REGEX=(var\S+)\s+=\s+[^\"]+([^\"]+)
FORMAT = $1::$2
CLEAN_KEYS = true

koshyk
Super Champion

cheers. it worked. I had to make a slight amendment, but the concept is the same.

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