From 144f20a0d26f0aabb7e7f410e9adfd6b51193461 Mon Sep 17 00:00:00 2001 From: Sebastian Spaink <3441183+sspaink@users.noreply.github.com> Date: Thu, 7 Oct 2021 14:47:59 -0500 Subject: [PATCH] fix: migrate to cloud.google.com/go/monitoring/apiv3/v2 (#9880) (cherry picked from commit 15753a6f7fa065248a19d534582fc7b79e0afe12) --- plugins/inputs/stackdriver/stackdriver.go | 6 +++--- plugins/outputs/stackdriver/stackdriver.go | 4 ++-- plugins/outputs/stackdriver/stackdriver_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/inputs/stackdriver/stackdriver.go b/plugins/inputs/stackdriver/stackdriver.go index 885913f91dd1c..cc8b1a40a10a5 100644 --- a/plugins/inputs/stackdriver/stackdriver.go +++ b/plugins/inputs/stackdriver/stackdriver.go @@ -9,7 +9,7 @@ import ( "sync" "time" - monitoring "cloud.google.com/go/monitoring/apiv3" + monitoring "cloud.google.com/go/monitoring/apiv3/v2" googlepbduration "github.com/golang/protobuf/ptypes/duration" googlepbts "github.com/golang/protobuf/ptypes/timestamp" "github.com/influxdata/telegraf" @@ -397,7 +397,7 @@ func (s *Stackdriver) newTimeSeriesConf( StartTime: &googlepbts.Timestamp{Seconds: startTime.Unix()}, } tsReq := &monitoringpb.ListTimeSeriesRequest{ - Name: monitoring.MetricProjectPath(s.Project), + Name: fmt.Sprintf("projects/%s", s.Project), Filter: filter, Interval: interval, } @@ -533,7 +533,7 @@ func (s *Stackdriver) generatetimeSeriesConfs( ret := []*timeSeriesConf{} req := &monitoringpb.ListMetricDescriptorsRequest{ - Name: monitoring.MetricProjectPath(s.Project), + Name: fmt.Sprintf("projects/%s", s.Project), } filters := s.newListMetricDescriptorsFilters() diff --git a/plugins/outputs/stackdriver/stackdriver.go b/plugins/outputs/stackdriver/stackdriver.go index 4d561a27b5007..d4f660ff7c569 100644 --- a/plugins/outputs/stackdriver/stackdriver.go +++ b/plugins/outputs/stackdriver/stackdriver.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - monitoring "cloud.google.com/go/monitoring/apiv3" // Imports the Stackdriver Monitoring client package. + monitoring "cloud.google.com/go/monitoring/apiv3/v2" // Imports the Stackdriver Monitoring client package. googlepb "github.com/golang/protobuf/ptypes/timestamp" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal" @@ -218,7 +218,7 @@ func (s *Stackdriver) Write(metrics []telegraf.Metric) error { // Prepare time series request. timeSeriesRequest := &monitoringpb.CreateTimeSeriesRequest{ - Name: monitoring.MetricProjectPath(s.Project), + Name: fmt.Sprintf("projects/%s", s.Project), TimeSeries: timeSeries, } diff --git a/plugins/outputs/stackdriver/stackdriver_test.go b/plugins/outputs/stackdriver/stackdriver_test.go index 7ddaa44854620..8af553b374c53 100644 --- a/plugins/outputs/stackdriver/stackdriver_test.go +++ b/plugins/outputs/stackdriver/stackdriver_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - monitoring "cloud.google.com/go/monitoring/apiv3" + monitoring "cloud.google.com/go/monitoring/apiv3/v2" "github.com/golang/protobuf/proto" emptypb "github.com/golang/protobuf/ptypes/empty" googlepb "github.com/golang/protobuf/ptypes/timestamp"