From 454000000b5c4bfb47997c2b572167e6d055b18c Mon Sep 17 00:00:00 2001 From: StephenVarela <36381962+StephenVarela@users.noreply.github.com> Date: Tue, 29 Nov 2022 14:37:15 -0500 Subject: [PATCH] Support http metric alerts for load balancers (#1313) * Bump godo version to 1.91.1 * Support http metric alerts for load balancers * Refactor the alert type validation --- commands/monitoring.go | 59 ++++++++++--------- go.mod | 2 +- go.sum | 4 +- .../github.com/digitalocean/godo/CHANGELOG.md | 4 ++ vendor/github.com/digitalocean/godo/godo.go | 2 +- .../digitalocean/godo/monitoring.go | 14 +++-- vendor/modules.txt | 4 +- 7 files changed, 50 insertions(+), 39 deletions(-) diff --git a/commands/monitoring.go b/commands/monitoring.go index 35552e499..4815ec9e4 100644 --- a/commands/monitoring.go +++ b/commands/monitoring.go @@ -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 { diff --git a/go.mod b/go.mod index a87d29c74..d1fafd51c 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 830bd026e..8be25d537 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index d9cf04f70..803ba787d 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [v1.91.1] - 2022-11-23 + +- #582 - @StephenVarela - Load Balancers: Support new endpoints for http alerts + ## [v1.90.0] - 2022-11-16 - #571 - @kraai - Add WaitForAvailable diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index 854ff185e..7c15e92ff 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -21,7 +21,7 @@ import ( ) const ( - libraryVersion = "1.90.0" + libraryVersion = "1.91.1" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" diff --git a/vendor/github.com/digitalocean/godo/monitoring.go b/vendor/github.com/digitalocean/godo/monitoring.go index 44109ff46..5934c8757 100644 --- a/vendor/github.com/digitalocean/godo/monitoring.go +++ b/vendor/github.com/digitalocean/godo/monitoring.go @@ -27,10 +27,16 @@ const ( DropletFiveMinuteLoadAverage = "v1/insights/droplet/load_5" DropletFifteenMinuteLoadAverage = "v1/insights/droplet/load_15" - LoadBalancerCPUUtilizationPercent = "v1/insights/lbaas/avg_cpu_utilization_percent" - LoadBalancerConnectionUtilizationPercent = "v1/insights/lbaas/connection_utilization_percent" - LoadBalancerDropletHealth = "v1/insights/lbaas/droplet_health" - LoadBalancerTLSUtilizationPercent = "v1/insights/lbaas/tls_connections_per_second_utilization_percent" + LoadBalancerCPUUtilizationPercent = "v1/insights/lbaas/avg_cpu_utilization_percent" + LoadBalancerConnectionUtilizationPercent = "v1/insights/lbaas/connection_utilization_percent" + LoadBalancerDropletHealth = "v1/insights/lbaas/droplet_health" + LoadBalancerTLSUtilizationPercent = "v1/insights/lbaas/tls_connections_per_second_utilization_percent" + LoadBalancerIncreaseInHTTPErrorRatePercentage = "v1/insights/lbaas/increase_in_http_error_rate_percentage" + LoadBalancerIncreaseInHTTPErrorRateCount = "v1/insights/lbaas/increase_in_http_error_rate_count" + LoadBalancerHighHttpResponseTime = "v1/insights/lbaas/high_http_request_response_time" + LoadBalancerHighHttpResponseTime50P = "v1/insights/lbaas/high_http_request_response_time_50p" + LoadBalancerHighHttpResponseTime95P = "v1/insights/lbaas/high_http_request_response_time_95p" + LoadBalancerHighHttpResponseTime99P = "v1/insights/lbaas/high_http_request_response_time_99p" DbaasFifteenMinuteLoadAverage = "v1/dbaas/alerts/load_15_alerts" DbaasMemoryUtilizationPercent = "v1/dbaas/alerts/memory_utilization_alerts" diff --git a/vendor/modules.txt b/vendor/modules.txt index b58d218c8..42dc0dbaf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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 @@ -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