From 4fad393227d53de5bc4bd5d1fde30148b137c26a Mon Sep 17 00:00:00 2001 From: Mario Castro Date: Mon, 1 Mar 2021 17:52:02 +0100 Subject: [PATCH] [Metricbeat] Google Cloud: Do not try to setup region filter on Cloudfunctions metrics (#24218) (#24232) (cherry picked from commit a6a3d6d8f332a65164ab6798b5f8f39574e29b98) --- CHANGELOG.next.asciidoc | 1 + x-pack/metricbeat/module/gcp/constants.go | 10 +++++----- .../metricbeat/module/gcp/metrics/metrics_requester.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index e85258eb618..cbfb0032e5c 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -324,6 +324,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix ec2 metricset fields.yml and the integration test {pull}23726[23726] - Unskip s3_request integration test. {pull}23887[23887] - Add system.hostfs configuration option for system module. {pull}23831[23831] +- Fix GCP not able to request Cloudfunctions metrics if a region filter was set {pull}24218[24218] *Packetbeat* diff --git a/x-pack/metricbeat/module/gcp/constants.go b/x-pack/metricbeat/module/gcp/constants.go index 0953684e693..2b1723f9c7c 100644 --- a/x-pack/metricbeat/module/gcp/constants.go +++ b/x-pack/metricbeat/module/gcp/constants.go @@ -16,11 +16,11 @@ const ( // Metricsets / GCP services names const ( - ServiceCompute = "compute" - ServicePubsub = "pubsub" - ServiceLoadBalancing = "loadbalancing" - ServiceFirestore = "firestore" - ServiceStorage = "storage" + ServiceCloudFunctions = "cloudfunctions" + ServiceCompute = "compute" + ServiceLoadBalancing = "loadbalancing" + ServicePubsub = "pubsub" + ServiceStorage = "storage" ) //Paths within the GCP monitoring.TimeSeries response, if converted to JSON, where you can find each ECS field required for the output event diff --git a/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go b/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go index 1154819d198..8f398842bb1 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go +++ b/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go @@ -83,7 +83,7 @@ func (r *metricsRequester) Metrics(ctx context.Context, sdc metricsConfig, metri go func(mt string) { defer wg.Done() - r.logger.Debugf("For metricType %s, metricMeta = %s", mt, metricMeta) + r.logger.Debugf("For metricType %s, metricMeta = %d", mt, metricMeta) interval, aligner := getTimeIntervalAligner(metricMeta.ingestDelay, metricMeta.samplePeriod, r.config.period, aligner) ts := r.Metric(ctx, mt, interval, aligner) lock.Lock() @@ -109,7 +109,7 @@ func (r *metricsRequester) getFilterForMetric(m string) (f string) { service := serviceRegexp.ReplaceAllString(m, "${service}") switch service { - case gcp.ServicePubsub, gcp.ServiceLoadBalancing: + case gcp.ServicePubsub, gcp.ServiceLoadBalancing, gcp.ServiceCloudFunctions: return case gcp.ServiceStorage: if r.config.Region == "" {