From f1ff9baf40c0ed1a4b19c676ad1dfb4491f1be35 Mon Sep 17 00:00:00 2001 From: sayden Date: Wed, 24 Feb 2021 17:00:45 +0100 Subject: [PATCH 1/4] Do not modify the filters of Google Cloud Functions like we already do in PubSub and LoadBalancing --- x-pack/metricbeat/module/gcp/constants.go | 1 + x-pack/metricbeat/module/gcp/metrics/metrics_requester.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/metricbeat/module/gcp/constants.go b/x-pack/metricbeat/module/gcp/constants.go index 0953684e693..0631f8a0dff 100644 --- a/x-pack/metricbeat/module/gcp/constants.go +++ b/x-pack/metricbeat/module/gcp/constants.go @@ -19,6 +19,7 @@ const ( ServiceCompute = "compute" ServicePubsub = "pubsub" ServiceLoadBalancing = "loadbalancing" + ServiceCloudFunctions = "cloudfunctions" ServiceFirestore = "firestore" ServiceStorage = "storage" ) 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 == "" { From 9aa273bab431f7a5672c88c8bbb19e8bf1ff9ed0 Mon Sep 17 00:00:00 2001 From: sayden Date: Wed, 24 Feb 2021 17:39:50 +0100 Subject: [PATCH 2/4] Add Changelog entry --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 2bb5ff66ef4..a71882d43f3 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -508,6 +508,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* From eda56b20f662055922aaf821c35345bbdb0b25e3 Mon Sep 17 00:00:00 2001 From: sayden Date: Wed, 24 Feb 2021 18:01:20 +0100 Subject: [PATCH 3/4] Reformat code --- x-pack/metricbeat/module/gcp/constants.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/metricbeat/module/gcp/constants.go b/x-pack/metricbeat/module/gcp/constants.go index 0631f8a0dff..74ebebc357e 100644 --- a/x-pack/metricbeat/module/gcp/constants.go +++ b/x-pack/metricbeat/module/gcp/constants.go @@ -16,12 +16,12 @@ const ( // Metricsets / GCP services names const ( - ServiceCompute = "compute" - ServicePubsub = "pubsub" - ServiceLoadBalancing = "loadbalancing" + ServiceCompute = "compute" + ServicePubsub = "pubsub" + ServiceLoadBalancing = "loadbalancing" ServiceCloudFunctions = "cloudfunctions" - ServiceFirestore = "firestore" - ServiceStorage = "storage" + ServiceFirestore = "firestore" + 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 From ba0103b13f05fa70fb7a6a6a792443f3205c2c25 Mon Sep 17 00:00:00 2001 From: sayden Date: Wed, 24 Feb 2021 22:32:59 +0100 Subject: [PATCH 4/4] Sort service constants and remove firestore until we actually need it --- x-pack/metricbeat/module/gcp/constants.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/x-pack/metricbeat/module/gcp/constants.go b/x-pack/metricbeat/module/gcp/constants.go index 74ebebc357e..2b1723f9c7c 100644 --- a/x-pack/metricbeat/module/gcp/constants.go +++ b/x-pack/metricbeat/module/gcp/constants.go @@ -16,11 +16,10 @@ const ( // Metricsets / GCP services names const ( + ServiceCloudFunctions = "cloudfunctions" ServiceCompute = "compute" - ServicePubsub = "pubsub" ServiceLoadBalancing = "loadbalancing" - ServiceCloudFunctions = "cloudfunctions" - ServiceFirestore = "firestore" + ServicePubsub = "pubsub" ServiceStorage = "storage" )