Skip to content

Commit

Permalink
supporting check alert frequency (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: mnkg561 <[email protected]>
  • Loading branch information
mnkg561 authored Dec 6, 2021
1 parent 2783cbb commit 4cb6034
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/wavefrontalert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ type WavefrontAlertSpec struct {
// wants to use go lang template for a field but majority of the alerts can use the default values instead of providing in each and every alert config files.
// +optional
ExportedParamsDefaultValues OrderedMap `json:"exportedParamsDefaultValues,omitempty"`

//AlertCheckFrequency can be used to provide a different alert check frequency then the default 1min. Optional. This is in minutes
// +optional
AlertCheckFrequency int `json:"alertCheckFrequency,omitempty"`
}

// AlertType represents the type of the Alert in Wavefront. Defaults to CLASSIC alert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ spec:
additionalInformation:
description: Any additional information, such as a link to a run book.
type: string
alertCheckFrequency:
description: AlertCheckFrequency can be used to provide a different
alert check frequency then the default 1min. Optional. This is in
minutes
type: integer
alertName:
description: Name of the alert to be created in Wavefront
type: string
Expand Down
2 changes: 1 addition & 1 deletion config/samples/alertmanager_v1alpha1_wavefrontalert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
condition: ts(status.health)
displayExpression: ts(status.health)
minutes: 5
resolveAfterMinutes: 5
resolveAfterMinutes: 50
severity: severe
tags:
- test-alert
Expand Down
1 change: 1 addition & 0 deletions config/samples/alertmanager_v1alpha1_wavefrontalert3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
minutes: 50
resolveAfterMinutes: 5
severity: "{{.bar}}"
alertCheckFrequency: 5
exportedParams:
- foo
- bar
Expand Down
1 change: 1 addition & 0 deletions config/samples/alertmanager_v1alpha1_wavefrontalert4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
minutes: 50
resolveAfterMinutes: 5
severity: "{{.bar}}"
alertCheckFrequency: 5
exportedParams:
- foo
- bar
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.16.0
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 // indirect
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
//golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
golang.org/x/tools v0.1.7 // indirect
k8s.io/api v0.19.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef h1:fPxZ3Umkct3LZ8gK9nbk+DWDJ
golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744 h1:KzbpndAYEM+4oHRp9JmB2ewj0NHHxO3Z0g7Gus2O1kk=
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
3 changes: 3 additions & 0 deletions pkg/wavefront/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func ConvertAlertCRToWavefrontRequest(ctx context.Context, req v1alpha1.Wavefron
alert.Minutes = int(*req.Minutes)
alert.ResolveAfterMinutes = int(*req.ResolveAfter)
alert.Target = req.Target
if req.AlertCheckFrequency != 0 {
alert.CheckingFrequencyInMinutes = req.AlertCheckFrequency
}
log.V(1).Info("alert conversion is successful")
return nil
}

0 comments on commit 4cb6034

Please sign in to comment.