Hello. I am having trouble with a complicated query. Here's what I'm trying to do:
We have events from IIS w3svc1 logs which include requestor IPs. For example:
2018-09-03 15:47:10 yy.yy.yy.yy GET //Catalog/ year=2018-2019 80 - xx.xx.xx.xx WordPress/4.9.6;+https://somewhere.com https://somewhere.com/Public/Catalog/?year=2018-2019 200 0 0 62
We also have standard WinEventLog:Application events that include the username that authenticated but does not include the requestor IP address.
When the WinEventLog:Application event has "MESSAGE="Login success", I want to correlate that event with the w3svc1 access log event at the same exact time stamp.
In other words, I want to determine which user successfully logged in at a specific time by referencing two separate logs. I can create the two separate queries, I'm unsure how to connect the two. With the help of DalJeanis below, I have the following so far:
(index=wineventlog host=somehost* USER=johndoe MESSAGE="Login success") OR (index=ag host=somehost* user="-" NOT requestor_ip=1.2.3.4 NOT requestor_ip=5.6.7.8 NOT username=*bot*)
| fields USER, requestor_ip
| eval new_time=if(match(sourcetype,"wineventlog"), _time-10,_time)
| sort 0 new_time
| streamstats time_window=30s last(USER) as USER
| where match(sourcetype,"w3svc1")
I see where this is going... but I'm having trouble with streamstats complaining:
Error in 'streamstats' command: time_window can only be used on input that is sorted in time order (both ascending and descending order are ok)
I think the issue is that I'm having trouble with the match function in the eval. I'm not sure what was meant in the comment by "Type A record" and Type B record. My guess was that it's a way to distinguish between the two searches, so I used their sourcetypes for comparison. Maybe that's the wrong approach?
To work around the error, I tried this:
(index=wineventlog host=somehost* USER=johndoe MESSAGE="Login success") OR (index=ag host=somehost* user="-" NOT requestor_ip=1.2.3.4 NOT requestor_ip=5.6.7.8 NOT username=*bot*)
| transaction requestor_ip maxspan=30s
| fields USER, requestor_ip
| eval new_time=if(match(sourcetype,"wineventlog"), _time-10,_time)
| sort 0 new_time
| streamstats last(USER) as USER
| where match(sourcetype,"w3svc1")
The problem is it's returning over 5000 results for the past 24 hours. It should only be returning maybe 2 or 3. It's as if the USER=johndoe constraint isn't working... Upon closer inspection, it looks like it's not even performing search A...
Thanks!
... View more