Atlantiraptor Docs

generate

Type: Function

Create a named generator that receives rows from the query.

This plugin allow multiple queries to efficiently filter rows from the same query.

Example

LET SystemLog = generate(query={
   SELECT * FROM parse_evtx(filename='''C:\Windows\system32\winevt\logs\System.evtx''')
})

SELECT timestamp(epoch=System.TimeCreated.SystemTime) AS Timestamp,
   Type, EventData
FROM combine(
a={
  SELECT *, "Kernel Driver Install" AS Type
  FROM SystemLog
  WHERE System.EventID.Value = 7045 AND EventData.ServiceType =~ "kernel"
}, b={
  SELECT *, "Log File Cleared" AS Type,
            UserData.LogFileCleared AS EventData
  FROM SystemLog
  WHERE System.EventID.Value = 104
})

Notes

The generate() function produces a stored query that can be used as the target of any SELECT ... FROM statement. Therefore it does not make sense to materialize the output of generate() because it is equivalent to materializing the actual target query itself.

In other words this:

LET X <= generate(query={ SELECT * FROM watch_etw(...) })

Will attempt to enumerate the target query into an array and is equivalent to:

LET X <= SELECT * FROM watch_etw(...)

Neither of those queries will terminate as VQL waits for them to produce all their rows before moving to the next statement but the watch_etw() query will never terminate since it is an event query.

Argument Type Description
name string Name to call the generator
query StoredQuery Run this query to generator rows.
delay int64 Wait before starting the query
with_file_buffer bool Enable file buffering
fan_out int64 Wait for this many listeners to connect before starting the query
description string A description to add to debug server

Platforms: macOS, Linux, Windows