From 09ba450b7f78d29e57a42bf191a4cbe533a28355 Mon Sep 17 00:00:00 2001 From: gab Date: Sun, 10 Jul 2022 22:15:43 +0300 Subject: [PATCH 1/2] add check for nil metadata --- .../metricbeat/module/gcp/metrics/metricset.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/x-pack/metricbeat/module/gcp/metrics/metricset.go b/x-pack/metricbeat/module/gcp/metrics/metricset.go index 47cd71a7725..99e43e09876 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metricset.go +++ b/x-pack/metricbeat/module/gcp/metrics/metricset.go @@ -322,14 +322,16 @@ func (m *MetricSet) getMetadata(out *metric.MetricDescriptor, metricsWithMeta ma ingestDelay: 0 * time.Second, } - if out.Metadata.SamplePeriod != nil { - m.Logger().Debugf("For metric type %s: sample period = %s", out.Type, out.Metadata.SamplePeriod) - meta.samplePeriod = time.Duration(out.Metadata.SamplePeriod.Seconds) * time.Second - } + if out.Metadata != nil { + if out.Metadata.SamplePeriod != nil { + m.Logger().Debugf("For metric type %s: sample period = %s", out.Type, out.Metadata.SamplePeriod) + meta.samplePeriod = time.Duration(out.Metadata.SamplePeriod.Seconds) * time.Second + } - if out.Metadata.IngestDelay != nil { - m.Logger().Debugf("For metric type %s: ingest delay = %s", out.Type, out.Metadata.IngestDelay) - meta.ingestDelay = time.Duration(out.Metadata.IngestDelay.Seconds) * time.Second + if out.Metadata.IngestDelay != nil { + m.Logger().Debugf("For metric type %s: ingest delay = %s", out.Type, out.Metadata.IngestDelay) + meta.ingestDelay = time.Duration(out.Metadata.IngestDelay.Seconds) * time.Second + } } metricsWithMeta[out.Type] = meta From 40d45207ac5b56d6b60a86e08e6b433046f6452e Mon Sep 17 00:00:00 2001 From: gab Date: Wed, 13 Jul 2022 19:28:23 +0300 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index e0c003f1be6..390306d6299 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -64,6 +64,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff] - Fix kubernetes module's internal cache expiration issue. This avoid metrics like `kubernetes.container.cpu.usage.limit.pct` from not being populated. {pull}31785[31785] - add missing HealthyHostCount and UnHealthyHostCount for application ELB. {pull}31853[31853] - update kubernetes apiserver metricset to not collect deprecated metrics and fix dashboard {pull}31973[31973] +- Check for nil metadata in GCP. {pull}32281[32281] *Packetbeat*