Splunk Search

The stats command collect data together if the value is the same

sarit_s
Communicator

Hello
im running this query:
((index=ssys_internal_fdm OR index=other_fdm) AND sourcetype!=machine)

source=*
| stats values(*) as * earliest(_time) as first_time latest(_time) as last_time by SerialNumber 
| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(first_time) as first_time ctime(last_time) as last_time
| search SerialNumber=D00520
| table Region  PrinterType SerialNumber first_time last_time

since this SerialNumber exists in two indexes im getting this result:

> Region    PrinterType     SerialNumber    first_time                 last_time
 INTERNAL      Dorado_F370    D00520           2019-03-20 00:15:10      2019-06-17 19:52:05
 OTHER           Stratasys F370

this is a very good result for another report but i need it to be in separate rows
is it possible ?

thanks

Tags (2)
0 Karma
1 Solution

harsmarvania57
Ultra Champion

Hi,

If you want result based on SerialNumber and Index then please try below query

((index=ssys_internal_fdm OR index=other_fdm) AND sourcetype!=machine)
source=*
| stats values(*) as * earliest(_time) as first_time latest(_time) as last_time by SerialNumber, index 
| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(first_time) as first_time ctime(last_time) as last_time
| search SerialNumber=D00520
| table Region  PrinterType SerialNumber first_time last_time

View solution in original post

0 Karma

harsmarvania57
Ultra Champion

Hi,

If you want result based on SerialNumber and Index then please try below query

((index=ssys_internal_fdm OR index=other_fdm) AND sourcetype!=machine)
source=*
| stats values(*) as * earliest(_time) as first_time latest(_time) as last_time by SerialNumber, index 
| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(first_time) as first_time ctime(last_time) as last_time
| search SerialNumber=D00520
| table Region  PrinterType SerialNumber first_time last_time
0 Karma

sarit_s
Communicator

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