Skip to content

Commit

Permalink
cmd/tetra: Add option to filter events based on policy names
Browse files Browse the repository at this point in the history
Closes #1855

Signed-off-by: Ioannis Androulidakis <androulidakis.ioannis@gmail.com>
  • Loading branch information
ioandr authored and willfindlay committed Jan 16, 2024
1 parent 88d1834 commit 5361282
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/tetra/getevents/getevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Opts struct {
Timestamps bool
TTYEncode string
StackTraces bool
PolicyNames []string
}

var Options Opts
Expand Down Expand Up @@ -97,6 +98,10 @@ var GetFilter = func() *tetragon.Filter {
filter.EventSet = append(filter.EventSet, eventType)
}
}
if len(Options.PolicyNames) > 0 {
filter.PolicyNames = Options.PolicyNames
}

return &filter
}

Expand Down Expand Up @@ -214,5 +219,6 @@ func New() *cobra.Command {
flags.BoolVar(&Options.Timestamps, "timestamps", false, "Include timestamps in compact output")
flags.StringVarP(&Options.TTYEncode, "tty-encode", "t", "", "Encode terminal data by file path (all other events will be ignored)")
flags.BoolVar(&Options.StackTraces, "stack-traces", true, "Include stack traces in compact output")
flags.StringSliceVar(&Options.PolicyNames, "policy-names", nil, "Get events by tracing policy names")
return &cmd
}

0 comments on commit 5361282

Please sign in to comment.