Splunk Search

Alphabetically sorting a MVfield

rvsroe
Explorer

Hi All,

I'm trying to combine a number of fields using:

| stats values(task_name) as task_name by idnumber


This works great when it comes to timestamps associated with the idnumber, but for
the tasks associated with it, splunk sorts it alphabetically.

This leads to problems down the line when we try to see which task was executed first.

Part of the problem is that the number of timestamps can differ from the number of tasks
so to make a new field with timestamp and task combined does not work.

#original data:
sysmodtime,task_name,idnumber
05/01/20 12:00 PM,one,1
05/01/20 12:01 AM,two,1
05/01/20 12:02 AM,two,1
05/01/20 12:02 AM,two,1
05/02/20 12:00 PM,one,2
04/02/20 12:00 AM,one,2
04/02/20 01:00 AM,one,2
04/02/20 02:00 AM,one,3
05/04/20 12:00 PM,one,4
05/03/20 12:00 PM,two,4
05/03/20 12:01 PM,three,4
05/03/20 12:02 PM,four,4
05/03/20 12:40 PM,five,4
05/03/20 12:50 PM,six,4


#the conflicting results after stats command (see attachment)

Any advice would be welcome
Cheers,
Roelof

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It's not clear what results you want.  Can you provide a mockup of the desired output?

Have you tried putting both columns in the stats command?

| stats values(*) as * by idnumber
---
If this reply helps you, Karma would be appreciated.
0 Karma

rvsroe
Explorer

Hi Richgalloway, thanks for the reply, the atachment in the main question shows the erroneous results, with the tasks sorted alphabetically instead of matched with the timestamp, so for example for id number 1 there are 6 tasks and 6 time stamps,  the stats command (placing both columns inside stats) gives:

sysmodtime, task_name, idnumber
05/04/20 12:00 PM, five, 4
05/03/20 12:00 PM, four,
05/03/20 12:01 PM, one,
05/03/20 12:02 PM, six.
05/03/20 12:40 PM, three,
05/03/20 12:50 PM, two,

whereas the order should be simply; one, two, three, four, five, six

Solutions that make a new field using sysmodtime and task_name fail since number of tasks
and number of sysmodtime are not equal in all cases.

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