Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x](backport #26982) [Metricbeat] gcp: log metrics without descriptors #27227

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion x-pack/metricbeat/module/gcp/metrics/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ func (m *MetricSet) metricDescriptor(ctx context.Context, client *monitoring.Met

for _, sdc := range m.MetricsConfig {
for _, mt := range sdc.MetricTypes {
req.Filter = fmt.Sprintf(`metric.type = starts_with("%s")`, sdc.AddPrefixTo(mt))
id := sdc.AddPrefixTo(mt)
req.Filter = fmt.Sprintf(`metric.type = starts_with("%s")`, id)
it := client.ListMetricDescriptors(ctx, req)

for {
Expand All @@ -263,6 +264,14 @@ func (m *MetricSet) metricDescriptor(ctx context.Context, client *monitoring.Met
if err == iterator.Done {
break
}

}

// NOTE: if a metric is not added to the metricsWithMeta map is not collected subsequently.
// Such a case is an error, as the configuration is explicitly requesting a metric that the beat
// is not able to collect, so we provide a logging statement for this behaviour.
if _, ok := metricsWithMeta[id]; !ok {
m.Logger().Errorf("%s metric descriptor is empty, this metric will not be collected", mt)
}
}
}
Expand Down