Skip to content

Cherry-pick #16203 to 7.x: [Metricbeat] Add region to googlecloud module config#16492

Merged
kaiyan-sheng merged 2 commits intoelastic:7.xfrom
kaiyan-sheng:backport_16203_7.x
Feb 24, 2020
Merged

Cherry-pick #16203 to 7.x: [Metricbeat] Add region to googlecloud module config#16492
kaiyan-sheng merged 2 commits intoelastic:7.xfrom
kaiyan-sheng:backport_16203_7.x

Conversation

@kaiyan-sheng
Copy link
Copy Markdown
Contributor

Cherry-pick of PR #16203 to 7.x branch. Original message:

What does this PR do?

This PR is to add region as a config parameter in googlecloud module. If region is specified, instances in all zones under that region will be collected.

Why is it important?

This way, if users need to collect metrics from us-west-1a, us-west-1b and us-west-1c, they don't need to specify one section of config for each zone in googlecloud.yml. For example:

- module: googlecloud
  metricsets:
    - compute
  zone: "us-west-1a"
  project_id: elastic-observability
  credentials_file_path: "/Users/kaiyansheng/Downloads/elastic-observability-d17781618202.json"
  exclude_labels: false
  period: 300s
- module: googlecloud
  metricsets:
    - compute
  zone: "us-west-1b"
  project_id: elastic-observability
  credentials_file_path: "/Users/kaiyansheng/Downloads/elastic-observability-d17781618202.json"
  exclude_labels: false
  period: 300s
- module: googlecloud
  metricsets:
    - compute
  zone: "us-west-1c"
  project_id: elastic-observability
  credentials_file_path: "/Users/kaiyansheng/Downloads/elastic-observability-d17781618202.json"
  exclude_labels: false
  period: 300s

Instead, with this PR, only region: us-west-1 is needed in the config:

- module: googlecloud
  metricsets:
    - compute
  region: "us-west-1"
  project_id: elastic-observability
  credentials_file_path: "/Users/kaiyansheng/Downloads/elastic-observability-d17781618202.json"
  exclude_labels: false
  period: 300s

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works

How to test this PR locally

Use config below, googlecloud metricset should collect compute metrics from all instances under us-central1 region, which includes us-central1-a, us-central1-b, us-central1-c, and us-central1-f.

- module: googlecloud
  metricsets:
    - compute
  region: "us-central1"
  project_id: elastic-observability
  credentials_file_path: "/Users/kaiyansheng/Downloads/elastic-observability-d17781618202.json"
  exclude_labels: false
  period: 300s

Related issues

* Add region to googlecloud module config

* Add changelog

* add warning when zone and region are both provided in config

* add more unit test for getFilterForMetric

* check if instance is nil before checking labels/machinetype

(cherry picked from commit f006db1)
@kaiyan-sheng kaiyan-sheng requested a review from a team as a code owner February 21, 2020 16:35
@kaiyan-sheng kaiyan-sheng self-assigned this Feb 21, 2020
@kaiyan-sheng kaiyan-sheng merged commit 9713877 into elastic:7.x Feb 24, 2020
@kaiyan-sheng kaiyan-sheng deleted the backport_16203_7.x branch February 24, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants