Splunk Enterprise

How to parse multivalued field to every line?

wvalente2
Explorer

Hello Splunkers.

I need help regarding a field with multiple values that must be separated.

I have the following log in the following format:

PostureReport
Policy_Umbrella;Passed
Policy_DLP;Passed
Policy_Kaspersky;Passed
Policy_Domain;Passed
Policy_SCCM;Passed
Police_Firewall_Windows;Failed
Policy_Crownstrike;Passed

I need to separate every Policy with your status.

I tried to use mvindex, mvjoin and them separate the events, mvexpand, but none of these worked for me.

 

Thank you.

 

 

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Assuming the Police_Firewall_Windows was Policy and it is a single field in a single event, then use rex 

| rex field=PostureReport max_match=0 "Policy_(?<Policy>[^;]*);(?<Status>.*)"

which will give you two multi-value fields Policy and Status.

If you want to create separate events for each policy result, then do this instead

| rex field=PostureReport max_match=0 "Policy_(?<Policy_Status>.*)"
| fields - PostureReport
| mvexpand Policy_Status
| rex field=Policy_Status "(?<Policy>[^;]*);(?<Status>.*)"

which will give you a separate event per Policy/Status pair

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Assuming the Police_Firewall_Windows was Policy and it is a single field in a single event, then use rex 

| rex field=PostureReport max_match=0 "Policy_(?<Policy>[^;]*);(?<Status>.*)"

which will give you two multi-value fields Policy and Status.

If you want to create separate events for each policy result, then do this instead

| rex field=PostureReport max_match=0 "Policy_(?<Policy_Status>.*)"
| fields - PostureReport
| mvexpand Policy_Status
| rex field=Policy_Status "(?<Policy>[^;]*);(?<Status>.*)"

which will give you a separate event per Policy/Status pair

0 Karma

wvalente2
Explorer

The first query work perfectly. I'll try here the final query that I want.

Thank you.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Assuming each line in the log is a separate event then you can use the split function to separate the fields.

| eval policyStatus = split(PostureReport, ";")
| eval policy = mvindex(policyStatus, 0), status = mvindex(policyStatus, 1)

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...