Splunk Search

How to merge 2 messages into 1 message?

ceng
New Member

Hi,

Is there a way to merge 2 messages into 1 message? For example I have a sequence of messages:

TestingData numTests=3
TestingCompleted start=10:00am end=3:00pm
TestingData numTest=2
TestingCompleted start=11:00am end=1:00pm

I would like this to look like below where 1+2 are merged and 3+4 are merged.

TestingData numTests=3  start=10:00am end=3:00pm
TestingData numTest=2 start=11:00am end=1:00pm

If either a TestingData or TestingCompleted row was missing then NA for that element of the merged row. So, if row 1 was missing then we would have below. The msg sequence order is fairly guaranteed.

NA  start=10:00am end=3:00pm
TestingData numTest=2 start=11:00am end=1:00pm

Thanks!

Tags (2)
0 Karma
1 Solution

yannK
Splunk Employee
Splunk Employee

It would be much easier if you were repeating the numTest on each line (to use a common grouping value)

You can try to regroup with a transaction at search time.
see http://docs.splunk.com/Documentation/Splunk/6.3.3/SearchReference/Transaction

look at the "startswith" and "endswith" options.

View solution in original post

0 Karma

yannK
Splunk Employee
Splunk Employee

It would be much easier if you were repeating the numTest on each line (to use a common grouping value)

You can try to regroup with a transaction at search time.
see http://docs.splunk.com/Documentation/Splunk/6.3.3/SearchReference/Transaction

look at the "startswith" and "endswith" options.

0 Karma

ceng
New Member

It works with this, thanks!

0 Karma

somesoni2
Revered Legend

Do your events have any common fields based which they can be merged??

0 Karma

ceng
New Member

No, there are none! I was thinking it might be -- take if the first row contains "TestingData" (else first row is set to "NA") and then merge with the next row if it contains "TestingCompleted" (else if second row is missing then set to "NA"), so it would be more like a row count type of thing instead of anything solid like an id field ... but I'm not sure if that's the best way.

And I'm not sure how to accomplish the above either, so any help is appreciated. Thanks!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...