Getting Data In

Joining two search based on closest time

eidil
Explorer

I am trying to join two searches based on closest time to match ticketnum with its real event e.g.

index=monitoring,

12:01:00 host=abc  status=down

3:05:00  host=abc status=down

index=ticket

12.03:00 host=abc  ticketnum=inc123

3:07:00 host=abc  ticketnum=inc456

Any idea on how to join these two based on closest time?

 

0 Karma
1 Solution

thambisetty
SplunkTrust
SplunkTrust

try something like below

 

index=monitoring OR index=ticket
| stats values(*) as * values(status) as status values(ticketnum) as ticketnum by _time, host
| streamstats last(status) as last_status by host
| fields - status
| where isnotnull(ticketnum)

 

 

Annotation 2020-09-08 082005.png 

like answer if it solves your problem.

————————————
If this helps, give a like below.

View solution in original post

thambisetty
SplunkTrust
SplunkTrust

that you would know which fields are required in report. I provided solution based on your query. please provide details.

————————————
If this helps, give a like below.
0 Karma

eidil
Explorer

Somethg like this

0 Karma

eidil
Explorer

eidil_0-1599720109186.png

 

0 Karma

thambisetty
SplunkTrust
SplunkTrust

@eidil 

check my updated answer : added values(*) as * to stats command

————————————
If this helps, give a like below.
0 Karma

thambisetty
SplunkTrust
SplunkTrust

try something like below

 

index=monitoring OR index=ticket
| stats values(*) as * values(status) as status values(ticketnum) as ticketnum by _time, host
| streamstats last(status) as last_status by host
| fields - status
| where isnotnull(ticketnum)

 

 

Annotation 2020-09-08 082005.png 

like answer if it solves your problem.

————————————
If this helps, give a like below.

eidil
Explorer

Hi @thambisetty , it seems d-able but the real logs are having much more details.  How do we know which fields needs to be written in the streamstats command?

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...