Splunk Search

How do I join on fields from two different sources with the two events being no more than 1 minute apart?

dpanych
Communicator

I have two sources (the CM logs and print logs) where I'm trying to join on the User field, but I also want to return results only when the print log follows the CM log no more than 1 minute later.

By concept, this is what I have so far but it doesn't work:

(index=ABC Screen="DocDetl" Func="ViewImg" FileName="Document" UsrID=*) OR (sourcetype=WinPrintMon type=PrintJob user=* "blah_blah.pdf") | where UsrID=user

What's the most efficient way to accomplish this?

woodcock
Esteemed Legend

Try this:

(index=ABC Screen="DocDetl" Func="ViewImg" FileName="Document" UsrID="*") OR (sourcetype=WinPrintMon type=PrintJob user="*" "blah_blah.pdf")
| eval JoinedUser=coalesce(UsrID,user)
| streamstats count(eval(sourcetype="WinPrintMon")) AS PrintSessionID BY JoinedUser
| eventstats latest(_time) AS PrintSessionTime by PrintSessionID JoinedUser
| eval KeepMe=if((((PrintSessionTime-_time) <= 60) AND NOT match(sourcetype,"^WinPrintMon$"))), "TRUE", null())
| eventstats dc(KeepMe) as KeepMeCount BY PrintSessionID JoinedUser
| where isnotnull(KeepMe) OR ((match(sourcetype,"^WinPrintMon$")) AND (KeepMeCount > 0))
0 Karma

dpanych
Communicator

Not quite this, this brought back other events which aren't needed.

0 Karma

woodcock
Esteemed Legend

I do not see how that is possible. It keeps only WinPrintMon events that have the other events that are closer than 1 minute earlier and also those other events.

0 Karma

dpanych
Communicator

The results I'm expecting is 2-3 events; the search you helped with results in 15 events, ranging within 7 hours of each other.

See the screenshot below. The left is the ABC data and right is print logs. I'm trying to create an alert when the criteria on the left is triggered and if within a minute there is a print log with that document name and user, I want to be alerted.
alt text

0 Karma

dpanych
Communicator
0 Karma

woodcock
Esteemed Legend

ARG! Cut/Paste stripped out some asterisk characters. I have re-edited the original answer. Try it now.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...