Skip to content

Commit

Permalink
Add source name to row (#3279)
Browse files Browse the repository at this point in the history
As discussed, this PR adds a _Source column to CLI/collector output to
make it easier to associate the results to a query. This is especially
useful when using JSON output and processing externally.
  • Loading branch information
weslambert authored and scudette committed Feb 14, 2024
1 parent a64dc05 commit ac788f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vql/tools/collector/collector_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,15 @@ func (self *collectionManager) collectQuery(
}
for row := range vql.Eval(self.ctx, subscope) {
status.ResultRows++
row_dict := vfilter.RowToDict(self.ctx, subscope, row)
if query.Name != "" {
row_dict.Set("_Source", query.Name)
}
select {
case <-self.ctx.Done():
query_log.Close()
return nil
case self.output_chan <- row:
case self.output_chan <- row_dict:
}
}
query_log.Close()
Expand Down

0 comments on commit ac788f7

Please sign in to comment.