Skip to content

Commit

Permalink
Support http metric alerts for load balancers (digitalocean#1313)
Browse files Browse the repository at this point in the history
* Bump godo version to 1.91.1

* Support http metric alerts for load balancers

* Refactor the alert type validation
  • Loading branch information
StephenVarela authored Nov 29, 2022
1 parent e176e7b commit 4540000
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 39 deletions.
59 changes: 31 additions & 28 deletions commands/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,36 +324,39 @@ func getComparator(compareStr string) (godo.AlertPolicyComp, error) {
}

func validateAlertPolicyType(t string) error {
switch t {
case godo.DropletCPUUtilizationPercent:
fallthrough
case godo.DropletMemoryUtilizationPercent:
fallthrough
case godo.DropletDiskUtilizationPercent:
fallthrough
case godo.DropletDiskReadRate:
fallthrough
case godo.DropletDiskWriteRate:
fallthrough
case godo.DropletOneMinuteLoadAverage:
fallthrough
case godo.DropletFiveMinuteLoadAverage:
fallthrough
case godo.DropletFifteenMinuteLoadAverage:
fallthrough
case godo.DropletPublicOutboundBandwidthRate:
fallthrough
case godo.DbaasFifteenMinuteLoadAverage:
fallthrough
case godo.DbaasMemoryUtilizationPercent:
fallthrough
case godo.DbaasDiskUtilizationPercent:
fallthrough
case godo.DbaasCPUUtilizationPercent:
return nil
default:
validAlertPolicyTypes := map[string]struct{}{
godo.DropletCPUUtilizationPercent: {},
godo.DropletMemoryUtilizationPercent: {},
godo.DropletDiskUtilizationPercent: {},
godo.DropletDiskReadRate: {},
godo.DropletDiskWriteRate: {},
godo.DropletOneMinuteLoadAverage: {},
godo.DropletFiveMinuteLoadAverage: {},
godo.DropletFifteenMinuteLoadAverage: {},
godo.DropletPublicOutboundBandwidthRate: {},
godo.DbaasFifteenMinuteLoadAverage: {},
godo.DbaasMemoryUtilizationPercent: {},
godo.DbaasDiskUtilizationPercent: {},
godo.DbaasCPUUtilizationPercent: {},
godo.LoadBalancerCPUUtilizationPercent: {},
godo.LoadBalancerDropletHealth: {},
godo.LoadBalancerTLSUtilizationPercent: {},
godo.LoadBalancerConnectionUtilizationPercent: {},
godo.LoadBalancerIncreaseInHTTPErrorRatePercentage: {},
godo.LoadBalancerIncreaseInHTTPErrorRateCount: {},
godo.LoadBalancerHighHttpResponseTime: {},
godo.LoadBalancerHighHttpResponseTime50P: {},
godo.LoadBalancerHighHttpResponseTime95P: {},
godo.LoadBalancerHighHttpResponseTime99P: {},
}

_, ok := validAlertPolicyTypes[t]

if !ok {
return errors.New(fmt.Sprintf("'%s' is not a valid alert policy type", t))
}

return nil
}

func validateAlertPolicyWindow(w string) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/containerd/continuity v0.3.0 // indirect
github.com/creack/pty v1.1.11
github.com/digitalocean/godo v1.90.0
github.com/digitalocean/godo v1.91.1
github.com/docker/cli v20.10.17+incompatible
github.com/docker/docker v20.10.17+incompatible
github.com/docker/docker-credential-helpers v0.6.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8l
github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/digitalocean/godo v1.90.0 h1:mnluEWL5eXFNYnLzHFuwsPuXZsWmzGoMNYSLZi9QPgc=
github.com/digitalocean/godo v1.90.0/go.mod h1:NRpFznZFvhHjBoqZAaOD3khVzsJ3EibzKqFL4R60dmA=
github.com/digitalocean/godo v1.91.1 h1:1o30VOCu1aC6488qBd0SkQiBeAZ35RSTvLwCA1pQMhc=
github.com/digitalocean/godo v1.91.1/go.mod h1:NRpFznZFvhHjBoqZAaOD3khVzsJ3EibzKqFL4R60dmA=
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/cli v20.10.17+incompatible h1:eO2KS7ZFeov5UJeaDmIs1NFEDRf32PaqRpvoEkKBy5M=
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/digitalocean/godo/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/digitalocean/godo/godo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions vendor/github.com/digitalocean/godo/monitoring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ github.com/creack/pty
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
## explicit
github.com/davecgh/go-spew/spew
# github.com/digitalocean/godo v1.90.0
# github.com/digitalocean/godo v1.91.1
## explicit; go 1.18
github.com/digitalocean/godo
github.com/digitalocean/godo/metrics
Expand Down Expand Up @@ -477,8 +477,6 @@ golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/imports
golang.org/x/tools/internal/typeparams
# golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f
## explicit; go 1.11
# google.golang.org/appengine v1.6.7
## explicit; go 1.11
google.golang.org/appengine/internal
Expand Down

0 comments on commit 4540000

Please sign in to comment.