diff --git a/metricbeat/docs/modules/googlecloud.asciidoc b/metricbeat/docs/modules/googlecloud.asciidoc index bf4ea8404f2..fd0bd772cd4 100644 --- a/metricbeat/docs/modules/googlecloud.asciidoc +++ b/metricbeat/docs/modules/googlecloud.asciidoc @@ -244,14 +244,15 @@ metricbeat.modules: credentials_file_path: "your JSON credentials file path" exclude_labels: false period: 1m - service: compute - metrics: - - aligner: ALIGN_NONE - metric_types: - - "compute.googleapis.com/instance/cpu/reserved_cores" - - "compute.googleapis.com/instance/cpu/usage_time" - - "compute.googleapis.com/instance/cpu/utilization" - - "compute.googleapis.com/instance/uptime" + stackdriver: + service: compute + metrics: + - aligner: ALIGN_NONE + metric_types: + - "compute.googleapis.com/instance/cpu/reserved_cores" + - "compute.googleapis.com/instance/cpu/usage_time" + - "compute.googleapis.com/instance/cpu/utilization" + - "compute.googleapis.com/instance/uptime" ---- [float] diff --git a/x-pack/metricbeat/metricbeat.reference.yml b/x-pack/metricbeat/metricbeat.reference.yml index 6a2582a6c49..1b5327397a4 100644 --- a/x-pack/metricbeat/metricbeat.reference.yml +++ b/x-pack/metricbeat/metricbeat.reference.yml @@ -530,14 +530,15 @@ metricbeat.modules: credentials_file_path: "your JSON credentials file path" exclude_labels: false period: 1m - service: compute - metrics: - - aligner: ALIGN_NONE - metric_types: - - "compute.googleapis.com/instance/cpu/reserved_cores" - - "compute.googleapis.com/instance/cpu/usage_time" - - "compute.googleapis.com/instance/cpu/utilization" - - "compute.googleapis.com/instance/uptime" + stackdriver: + service: compute + metrics: + - aligner: ALIGN_NONE + metric_types: + - "compute.googleapis.com/instance/cpu/reserved_cores" + - "compute.googleapis.com/instance/cpu/usage_time" + - "compute.googleapis.com/instance/cpu/utilization" + - "compute.googleapis.com/instance/uptime" #------------------------------- Graphite Module ------------------------------- - module: graphite diff --git a/x-pack/metricbeat/module/googlecloud/_meta/config.yml b/x-pack/metricbeat/module/googlecloud/_meta/config.yml index 6a56af4e1bd..8103b2c111a 100644 --- a/x-pack/metricbeat/module/googlecloud/_meta/config.yml +++ b/x-pack/metricbeat/module/googlecloud/_meta/config.yml @@ -32,11 +32,12 @@ credentials_file_path: "your JSON credentials file path" exclude_labels: false period: 1m - service: compute - metrics: - - aligner: ALIGN_NONE - metric_types: - - "compute.googleapis.com/instance/cpu/reserved_cores" - - "compute.googleapis.com/instance/cpu/usage_time" - - "compute.googleapis.com/instance/cpu/utilization" - - "compute.googleapis.com/instance/uptime" + stackdriver: + service: compute + metrics: + - aligner: ALIGN_NONE + metric_types: + - "compute.googleapis.com/instance/cpu/reserved_cores" + - "compute.googleapis.com/instance/cpu/usage_time" + - "compute.googleapis.com/instance/cpu/utilization" + - "compute.googleapis.com/instance/uptime" diff --git a/x-pack/metricbeat/module/googlecloud/stackdriver/metricset.go b/x-pack/metricbeat/module/googlecloud/stackdriver/metricset.go index 7bc70929686..e31aa96202c 100644 --- a/x-pack/metricbeat/module/googlecloud/stackdriver/metricset.go +++ b/x-pack/metricbeat/module/googlecloud/stackdriver/metricset.go @@ -106,7 +106,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { return nil, errors.Wrap(err, "error creating Stackdriver client") } - m.metricsMeta, err = metricDescriptor(ctx, client, m.config.ProjectID, m.stackDriverConfig) + m.metricsMeta, err = m.metricDescriptor(ctx, client) if err != nil { return nil, errors.Wrap(err, "error calling metricDescriptor function") } @@ -205,13 +205,13 @@ func (mc *stackDriverConfig) Validate() error { // metricDescriptor calls ListMetricDescriptorsRequest API to get metric metadata // (sample period and ingest delay) of each given metric type -func metricDescriptor(ctx context.Context, client *monitoring.MetricClient, projectID string, stackDriverConfigs []stackDriverConfig) (map[string]metricMeta, error) { +func (m *MetricSet) metricDescriptor(ctx context.Context, client *monitoring.MetricClient) (map[string]metricMeta, error) { metricsWithMeta := make(map[string]metricMeta, 0) - for _, sdc := range stackDriverConfigs { + for _, sdc := range m.stackDriverConfig { for _, mt := range sdc.MetricTypes { req := &monitoringpb.ListMetricDescriptorsRequest{ - Name: "projects/" + projectID, + Name: "projects/" + m.config.ProjectID, Filter: fmt.Sprintf(`metric.type = "%s"`, mt), } @@ -228,10 +228,12 @@ func metricDescriptor(ctx context.Context, client *monitoring.MetricClient, proj } if out.Metadata.SamplePeriod != nil { + m.Logger().Debugf("For metric type %s: sample period = %s", mt, 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", mt, out.Metadata.IngestDelay) meta.ingestDelay = time.Duration(out.Metadata.IngestDelay.Seconds) * time.Second } diff --git a/x-pack/metricbeat/modules.d/googlecloud.yml.disabled b/x-pack/metricbeat/modules.d/googlecloud.yml.disabled index 2ad466ac15d..aecd41c1ee3 100644 --- a/x-pack/metricbeat/modules.d/googlecloud.yml.disabled +++ b/x-pack/metricbeat/modules.d/googlecloud.yml.disabled @@ -35,11 +35,12 @@ credentials_file_path: "your JSON credentials file path" exclude_labels: false period: 1m - service: compute - metrics: - - aligner: ALIGN_NONE - metric_types: - - "compute.googleapis.com/instance/cpu/reserved_cores" - - "compute.googleapis.com/instance/cpu/usage_time" - - "compute.googleapis.com/instance/cpu/utilization" - - "compute.googleapis.com/instance/uptime" + stackdriver: + service: compute + metrics: + - aligner: ALIGN_NONE + metric_types: + - "compute.googleapis.com/instance/cpu/reserved_cores" + - "compute.googleapis.com/instance/cpu/usage_time" + - "compute.googleapis.com/instance/cpu/utilization" + - "compute.googleapis.com/instance/uptime"