We are attempting to write a report querying multiple indexes, which creates a table using data from each. Our challenge is... When we add indextime or _time the report shows all the indextime for each system in the date range selected. Instead, we want to show only the latest indextime/_time in the report only for each system.
(index=* sourcetype=ActiveDirectory objectCategory="CN=Computer,CN=Schema,CN=Configuration,DC=foo,DC=com") OR (index=windows DisplayName="BitLocker Drive Encryption Service" source="kiwi syslog server")
| eval indextime=strftime(_indextime,"%Y-%m-%d %H:%M:%S")
| eval cn=coalesce(cn,host) | stats values(*) AS * BY cn | search cn=* host=*
NOT [inputlookup All_Virtual_Machines.csv | rename Name as cn]
| where StartMode!="" AND operatingSystem!="" AND Started!="true"
| rename cn as System, operatingSystem as OS
| dedup System
| table System StartMode State Started OS indextime | sort System
It's because you're doing a values(*) in your stats command, which is bringing in every index time. If any of the other fields end up having more than one value, it'll also do the same thing for those.
try doing - using max(_indextime) in the stats command and moving the strftime to the bottom.
(index=* sourcetype=ActiveDirectory objectCategory="CN=Computer,CN=Schema,CN=Configuration,DC=g1net,DC=com") OR (index=windows DisplayName="BitLocker Drive Encryption Service" source="kiwi syslog server")
| eval cn=coalesce(cn,host) | stats values(*) AS * max(_indextime) as indextime BY cn | search cn=* host=*
NOT [inputlookup All_Virtual_Machines.csv | rename Name as cn]
| where StartMode!="" AND operatingSystem!="" AND Started!="true"
| rename cn as System, operatingSystem as OS
| dedup System
| table System StartMode State Started OS indextime | eval indextime=strftime(indextime,"%Y-%m-%d %H:%M:%S")| sort System
It's because you're doing a values(*) in your stats command, which is bringing in every index time. If any of the other fields end up having more than one value, it'll also do the same thing for those.
try doing - using max(_indextime) in the stats command and moving the strftime to the bottom.
(index=* sourcetype=ActiveDirectory objectCategory="CN=Computer,CN=Schema,CN=Configuration,DC=g1net,DC=com") OR (index=windows DisplayName="BitLocker Drive Encryption Service" source="kiwi syslog server")
| eval cn=coalesce(cn,host) | stats values(*) AS * max(_indextime) as indextime BY cn | search cn=* host=*
NOT [inputlookup All_Virtual_Machines.csv | rename Name as cn]
| where StartMode!="" AND operatingSystem!="" AND Started!="true"
| rename cn as System, operatingSystem as OS
| dedup System
| table System StartMode State Started OS indextime | eval indextime=strftime(indextime,"%Y-%m-%d %H:%M:%S")| sort System
Thank you cmerriman! That worked perfectly! I simply copied and pasted your revisions and it worked!