I get the feeling that optimization is the least of your problem here. I am trying to implement a behavioral rule, that checks if an ip was used in the last 7 days or not. ... [search index=<ind...
See more...
I get the feeling that optimization is the least of your problem here. I am trying to implement a behavioral rule, that checks if an ip was used in the last 7 days or not. ... [search index=<index>operationName="Sign-in activity" earliest=-7d@d | ...] It is just unclear what "used in the last 7 days" really mean because your mock code only constraints earliest. The default latest is now(). So, that mock code (if not for the code error that @bowesmana pointed out) would have been exactly the same as if the main search starts at earliest=-7d@d latest=now. In other words, you would have picked up everything from the beginning of the start of 7th day back to now(). There would have been no "false". @bowesmana interpreted your intention as thus: starting 7th day back, determine whether an IP address that appears in the current day had also appeared in the earlier days. Is this the correct interpretation? If that is the requirement, the following should make the distinction. index=<index> operationName="Sign-in activity" NOT body.properties.deviceDetail.displayName=* earliest=-7d@d ```latest=now```
| eval history = if(_time < relative_time(now(), "@d"), "today", "past7")
| stats values(history) as is_historical count by ipAddress
| where is_historical == "today" ``` shorthand for "today" IN is_historical ```
| eval is_historical = if(is_historical == "past7", "true", "false")