diff --git a/api/filter-alerts.go b/api/filter-alerts.go index 3a45f3e..7bdcfdd 100644 --- a/api/filter-alerts.go +++ b/api/filter-alerts.go @@ -7,15 +7,17 @@ import ( ) type FilterAlert struct { - ID string `graphql:"id" yaml:"-" json:"id"` - Name string `graphql:"name" yaml:"name" json:"name"` - Description string `graphql:"description" yaml:"description,omitempty" json:"description,omitempty"` - QueryString string `graphql:"queryString" yaml:"queryString" json:"queryString"` - ActionNames []string `graphql:"actionNames" yaml:"actionNames" json:"actionNames"` - Labels []string `graphql:"labels" yaml:"labels" json:"labels"` - Enabled bool `graphql:"enabled" yaml:"enabled" json:"enabled"` - QueryOwnershipType string `graphql:"queryOwnership" yaml:"queryOwnershipType" json:"queryOwnershipType"` - RunAsUserID string `graphql:"runAsUserId" yaml:"runAsUserId,omitempty" json:"runAsUserId,omitempty"` + ID string `graphql:"id" yaml:"-" json:"id"` + Name string `graphql:"name" yaml:"name" json:"name"` + Description string `graphql:"description" yaml:"description,omitempty" json:"description,omitempty"` + QueryString string `graphql:"queryString" yaml:"queryString" json:"queryString"` + ActionNames []string `graphql:"actionNames" yaml:"actionNames" json:"actionNames"` + Labels []string `graphql:"labels" yaml:"labels" json:"labels"` + Enabled bool `graphql:"enabled" yaml:"enabled" json:"enabled"` + QueryOwnershipType string `graphql:"queryOwnership" yaml:"queryOwnershipType" json:"queryOwnershipType"` + ThrottleTimeSeconds int `graphql:"throttleTimeSeconds" yaml:"throttleTimeSeconds,omitempty" json:"throttleTimeSeconds,omitempty"` + ThrottleField string `graphql:"throttleField" yaml:"throttleField,omitempty" json:"throttleField"` + RunAsUserID string `graphql:"runAsUserId" yaml:"runAsUserId,omitempty" json:"runAsUserId,omitempty"` } type FilterAlerts struct { @@ -72,16 +74,18 @@ func (fa *FilterAlerts) Update(viewName string, updatedFilterAlert *FilterAlert) } updateAlert := humiographql.UpdateFilterAlert{ - ViewName: humiographql.RepoOrViewName(viewName), - ID: graphql.String(updatedFilterAlert.ID), - Name: graphql.String(updatedFilterAlert.Name), - Description: graphql.String(updatedFilterAlert.Description), - QueryString: graphql.String(updatedFilterAlert.QueryString), - ActionIdsOrNames: actionNames, - Labels: labels, - Enabled: graphql.Boolean(updatedFilterAlert.Enabled), - RunAsUserID: graphql.String(updatedFilterAlert.RunAsUserID), - QueryOwnershipType: humiographql.QueryOwnershipType(updatedFilterAlert.QueryOwnershipType), + ViewName: humiographql.RepoOrViewName(viewName), + ID: graphql.String(updatedFilterAlert.ID), + Name: graphql.String(updatedFilterAlert.Name), + Description: graphql.String(updatedFilterAlert.Description), + QueryString: graphql.String(updatedFilterAlert.QueryString), + ActionIdsOrNames: actionNames, + Labels: labels, + Enabled: graphql.Boolean(updatedFilterAlert.Enabled), + RunAsUserID: graphql.String(updatedFilterAlert.RunAsUserID), + ThrottleTimeSeconds: humiographql.Long(updatedFilterAlert.ThrottleTimeSeconds), + ThrottleField: graphql.String(updatedFilterAlert.ThrottleField), + QueryOwnershipType: humiographql.QueryOwnershipType(updatedFilterAlert.QueryOwnershipType), } variables := map[string]any{ @@ -118,15 +122,17 @@ func (fa *FilterAlerts) Create(viewName string, newFilterAlert *FilterAlert) (*F } createFilterAlert := humiographql.CreateFilterAlert{ - ViewName: humiographql.RepoOrViewName(viewName), - Name: graphql.String(newFilterAlert.Name), - Description: graphql.String(newFilterAlert.Description), - QueryString: graphql.String(newFilterAlert.QueryString), - ActionIdsOrNames: actionNames, - Labels: labels, - Enabled: graphql.Boolean(newFilterAlert.Enabled), - RunAsUserID: graphql.String(newFilterAlert.RunAsUserID), - QueryOwnershipType: humiographql.QueryOwnershipType(newFilterAlert.QueryOwnershipType), + ViewName: humiographql.RepoOrViewName(viewName), + Name: graphql.String(newFilterAlert.Name), + Description: graphql.String(newFilterAlert.Description), + QueryString: graphql.String(newFilterAlert.QueryString), + ActionIdsOrNames: actionNames, + Labels: labels, + Enabled: graphql.Boolean(newFilterAlert.Enabled), + ThrottleTimeSeconds: humiographql.Long(newFilterAlert.ThrottleTimeSeconds), + ThrottleField: graphql.String(newFilterAlert.ThrottleField), + RunAsUserID: graphql.String(newFilterAlert.RunAsUserID), + QueryOwnershipType: humiographql.QueryOwnershipType(newFilterAlert.QueryOwnershipType), } variables := map[string]any{ @@ -209,14 +215,16 @@ func mapHumioGraphqlFilterAlertToFilterAlert(input humiographql.FilterAlert) Fil } return FilterAlert{ - ID: string(input.ID), - Name: string(input.Name), - Description: string(input.Description), - QueryString: string(input.QueryString), - ActionNames: actionNames, - Labels: labels, - Enabled: bool(input.Enabled), - QueryOwnershipType: queryOwnershipType, - RunAsUserID: runAsUserID, + ID: string(input.ID), + Name: string(input.Name), + Description: string(input.Description), + QueryString: string(input.QueryString), + ActionNames: actionNames, + Labels: labels, + Enabled: bool(input.Enabled), + ThrottleTimeSeconds: int(input.ThrottleTimeSeconds), + ThrottleField: string(input.ThrottleField), + QueryOwnershipType: queryOwnershipType, + RunAsUserID: runAsUserID, } } diff --git a/api/internal/humiographql/filter-alerts.go b/api/internal/humiographql/filter-alerts.go index 0407231..b612dde 100644 --- a/api/internal/humiographql/filter-alerts.go +++ b/api/internal/humiographql/filter-alerts.go @@ -5,14 +5,16 @@ import ( ) type FilterAlert struct { - ID graphql.String `graphql:"id"` - Name graphql.String `graphql:"name"` - Description graphql.String `graphql:"description"` - QueryString graphql.String `graphql:"queryString"` - Actions []Action `graphql:"actions"` - Labels []graphql.String `graphql:"labels"` - Enabled graphql.Boolean `graphql:"enabled"` - QueryOwnership QueryOwnership `graphql:"queryOwnership"` + ID graphql.String `graphql:"id"` + Name graphql.String `graphql:"name"` + Description graphql.String `graphql:"description"` + QueryString graphql.String `graphql:"queryString"` + Actions []Action `graphql:"actions"` + Labels []graphql.String `graphql:"labels"` + Enabled graphql.Boolean `graphql:"enabled"` + ThrottleTimeSeconds Long `graphql:"throttleTimeSeconds"` + ThrottleField graphql.String `graphql:"throttleField"` + QueryOwnership QueryOwnership `graphql:"queryOwnership"` } type Action struct { @@ -20,26 +22,30 @@ type Action struct { } type CreateFilterAlert struct { - ViewName RepoOrViewName `json:"viewName"` - Name graphql.String `json:"name"` - Description graphql.String `json:"description,omitempty"` - QueryString graphql.String `json:"queryString"` - ActionIdsOrNames []graphql.String `json:"actionIdsOrNames"` - Labels []graphql.String `json:"labels"` - Enabled graphql.Boolean `json:"enabled"` - RunAsUserID graphql.String `json:"runAsUserId,omitempty"` - QueryOwnershipType QueryOwnershipType `json:"queryOwnershipType"` + ViewName RepoOrViewName `json:"viewName"` + Name graphql.String `json:"name"` + Description graphql.String `json:"description,omitempty"` + QueryString graphql.String `json:"queryString"` + ActionIdsOrNames []graphql.String `json:"actionIdsOrNames"` + Labels []graphql.String `json:"labels"` + Enabled graphql.Boolean `json:"enabled"` + ThrottleTimeSeconds Long `json:"throttleTimeSeconds"` + ThrottleField graphql.String `json:"throttleField"` + RunAsUserID graphql.String `json:"runAsUserId,omitempty"` + QueryOwnershipType QueryOwnershipType `json:"queryOwnershipType"` } type UpdateFilterAlert struct { - ViewName RepoOrViewName `json:"viewName"` - ID graphql.String `json:"id"` - Name graphql.String `json:"name"` - Description graphql.String `json:"description,omitempty"` - QueryString graphql.String `json:"queryString"` - ActionIdsOrNames []graphql.String `json:"actionIdsOrNames"` - Labels []graphql.String `json:"labels"` - Enabled graphql.Boolean `json:"enabled"` - RunAsUserID graphql.String `json:"runAsUserId,omitempty"` - QueryOwnershipType QueryOwnershipType `json:"queryOwnershipType"` + ViewName RepoOrViewName `json:"viewName"` + ID graphql.String `json:"id"` + Name graphql.String `json:"name"` + Description graphql.String `json:"description,omitempty"` + QueryString graphql.String `json:"queryString"` + ActionIdsOrNames []graphql.String `json:"actionIdsOrNames"` + Labels []graphql.String `json:"labels"` + Enabled graphql.Boolean `json:"enabled"` + ThrottleTimeSeconds Long `json:"throttleTimeSeconds"` + ThrottleField graphql.String `json:"throttleField"` + RunAsUserID graphql.String `json:"runAsUserId,omitempty"` + QueryOwnershipType QueryOwnershipType `json:"queryOwnershipType"` } diff --git a/cmd/humioctl/filter_alerts_list.go b/cmd/humioctl/filter_alerts_list.go index d5b6712..b7f96e6 100644 --- a/cmd/humioctl/filter_alerts_list.go +++ b/cmd/humioctl/filter_alerts_list.go @@ -43,12 +43,14 @@ func newFilterAlertsListCmd() *cobra.Command { format.String(filterAlert.Description), format.String(strings.Join(filterAlert.ActionNames, ", ")), format.String(strings.Join(filterAlert.Labels, ", ")), + format.Int(filterAlert.ThrottleTimeSeconds), + format.String(filterAlert.ThrottleField), format.String(filterAlert.RunAsUserID), format.String(filterAlert.QueryOwnershipType), } } - printOverviewTable(cmd, []string{"ID", "Name", "Enabled", "Description", "Actions", "Labels", "Run As User ID", "Query Ownership Type"}, rows) + printOverviewTable(cmd, []string{"ID", "Name", "Enabled", "Description", "Actions", "Labels", "Throttle Time Seconds", "Throttle Field", "Run As User ID", "Query Ownership Type"}, rows) }, } diff --git a/cmd/humioctl/filter_alerts_show.go b/cmd/humioctl/filter_alerts_show.go index aef51fa..07f00bc 100644 --- a/cmd/humioctl/filter_alerts_show.go +++ b/cmd/humioctl/filter_alerts_show.go @@ -54,6 +54,8 @@ func newFilterAlertsShowCmd() *cobra.Command { {format.String("Query String"), format.String(filterAlert.QueryString)}, {format.String("Labels"), format.String(strings.Join(filterAlert.Labels, ", "))}, {format.String("Actions"), format.String(strings.Join(filterAlert.ActionNames, ", "))}, + {format.String("Throttle Time Seconds"), format.Int(filterAlert.ThrottleTimeSeconds)}, + {format.String("Throttle Field"), format.String(filterAlert.ThrottleField)}, {format.String("Run As User ID"), format.String(filterAlert.RunAsUserID)}, {format.String("Query Ownership Type"), format.String(filterAlert.QueryOwnershipType)}, }