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

[Metricbeat] gcp: add GKE metricset #26824

Merged
merged 10 commits into from
Aug 20, 2021
Merged

Conversation

endorama
Copy link
Member

@endorama endorama commented Jul 9, 2021

What does this PR do?

Add a lightweight module to pull GCP GKE metrics.

Metrics gathered are all GA metrics as of today available for Kubernetes on GCP.

GCP Docs: https://cloud.google.com/monitoring/api/metrics_kubernetes

Why is it important?

Implement GKE integration as requested in elastic/integrations#816

Dates

  • Development Start date: Tue, Aug 17 2021
  • Feature Freeze date: Wed, Aug 18 2021
  • Release date: Tue, Sep 21 2021

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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • [ ]

How to test this PR locally

You can build and run the metricbeat binary from this PR to collect GKE metrics. You may use this configuration for gcp.yml module:

- module: gcp
  metricsets:
    - gke
  zone: "us-"
  project_id: "<fill>"
  credentials_file_path: "<fill>"
  exclude_labels: false
  period: 1m

Related issues

Use cases

Feature: GKE metric collection

  GKE is the dedicated Kubernetes distribution from GCP. It exposes a set of dedicated 
  metrics useful for Kubernetes operators and developers.

  Scenario: Collect GKE specific metrics
	Given that gke metricset collection has been enabled and configured
    When running metricbeat
	Then I receive GKE specific metrics in Elasticsearch

Screenshots

Screenshot 2021-08-11 at 12-14-55  Metricbeat GCP  GKE Overview 2nd - Elastic

Logs

Metricbeat Module / Dataset release checklist

This checklist is intended for Devs which create or update a module to make sure modules are consistent.

Modules

For a metricset to go GA, the following criterias should be met:

gcp module is currently in beta.

Metricbeat module

  • Example data.json exists and an automated way to generate it exists (go test -data)
  • Test environment in Docker exist for integration tests

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 9, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 9, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-08-17T21:06:04.733+0000

  • Duration: 101 min 29 sec

  • Commit: 9dbbbaa

Test stats 🧪

Test Results
Failed 0
Passed 9495
Skipped 2519
Total 12014

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 9495
Skipped 2519
Total 12014

@mtojek mtojek self-requested a review July 12, 2021 07:04
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start, keep pushing the missing items. You can copy the TODO list from the template: https://github.com/elastic/beats/issues/new?assignees=&labels=&template=module-checklist.md

I think that the next step is to make it working and passing lint.

metrics:
- service: gke
metric_types:
- "container/cpu/core_usage_time"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To review available metrics, you can sync with @sorantis .

description: Memory limit of the container in bytes. Sampled every 60 seconds.
- name: limit_utilization.value
type: double
description: The fraction of the memory limit that is currently in use on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we used pct for percentages. See:

  - name: memory.broker.pct
    description: The percentage of the memory limit used.
    type: scaled_float
    format: percent

Sometimes you need an additional Javascript processor to convert to the right format:

processors:
  - script:
      lang: javascript
      source: >
        function process(event) {
          var broker_memory_broker_pct = event.Get("activemq.broker.memory.broker.pct")
          if (broker_memory_broker_pct != null) {
            event.Put("activemq.broker.memory.broker.pct", broker_memory_broker_pct / 100.0)
          }

          var broker_memory_temp_pct = event.Get("activemq.broker.memory.temp.pct")
          if (broker_memory_temp_pct != null) {
            event.Put("activemq.broker.memory.temp.pct", broker_memory_temp_pct / 100.0)
          }

          var broker_memory_store_pct = event.Get("activemq.broker.memory.store.pct")
          if (broker_memory_store_pct != null) {
            event.Put("activemq.broker.memory.store.pct", broker_memory_store_pct / 100.0)
          }
        }

(based on the ActiveMQ module.

- name: used_bytes.value
type: long
description: Memory usage in bytes. Sampled every 60 seconds.
- name: ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. empty name?

- name: memory
type: group
fields:
- name: allocatable_bytes.value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be max_bytes or allocatable.bytes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case - memory.allocable.bytes. But this comment applies to all fields you submitted.

Copy link
Member Author

@endorama endorama Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Will update all occurrences

Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this PR is still in draft, just want to bring elastic/ecs#1441 to your attention. As a part of the inventory schema work, we are planning to add some additional container metrics. It would be good if you can adopt these fields in this new metricset 🙂

@endorama endorama force-pushed the xpack-gcp-gke branch 3 times, most recently from ea66269 to 8d22db0 Compare July 19, 2021 15:22
@endorama endorama force-pushed the xpack-gcp-gke branch 2 times, most recently from 3af2e22 to 28f4a83 Compare July 20, 2021 12:55
@endorama endorama changed the title add GCP GKE metricbeat metricset [Metricbeat] gcp: add GKE metricset Jul 20, 2021
@endorama
Copy link
Member Author

To keep consistency with the GCP documentation and implementation, I'll rename gke to kubernetes. It's the name used in the GCP docs so I think the consistency is a must here.

@kaiyan-sheng kaiyan-sheng added the Team:Integrations Label for the Integrations team label Jul 27, 2021
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 27, 2021
@endorama endorama added the backport-v7.15.0 Automated backport with mergify label Aug 4, 2021
@endorama endorama force-pushed the xpack-gcp-gke branch 2 times, most recently from 2a1afe1 to 7b36f30 Compare August 10, 2021 09:26
@endorama
Copy link
Member Author

Found a bug in #26960, fix split in #27286

@endorama
Copy link
Member Author

Added GKE overview dashboard. Preview:
Screenshot 2021-08-11 at 12-14-55  Metricbeat GCP  GKE Overview 2nd - Elastic

@endorama endorama force-pushed the xpack-gcp-gke branch 3 times, most recently from 4bc794d to 2b93129 Compare August 13, 2021 08:04
@endorama endorama marked this pull request as ready for review August 13, 2021 08:14
@endorama endorama force-pushed the xpack-gcp-gke branch 2 times, most recently from e73f364 to 7e70b34 Compare August 17, 2021 16:29
@endorama
Copy link
Member Author

#27416 has been merged

Rebasing onto master and triggering a new CI check.

Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Feel free to ship the dashboard separately.

@kaiyan-sheng
Copy link
Contributor

When shipping a dashboard, please also add a screenshot into this folder under Metricbeat. Also reference the dashboard screenshot in the documentation.

@endorama
Copy link
Member Author

I removed the dashboard... Now waiting on the CI

Add a lightweight module to pull GCP GKE metrics.

Metrics are all GA metrics as of today available for Kubernetes on GCP.

Docs: https://cloud.google.com/monitoring/api/metrics_kubernetes
In elastic#27231 I discovered that all `gcp` metricsets do not respect the
Beats naming conventions.

In order to preserve consistency across metricset this commit reverts
the changes that aligned the newly added metrics to naming conventions.
@jsoriano jsoriano added the backport-v7.16.0 Automated backport with mergify label Aug 20, 2021
@endorama endorama merged commit 1140740 into elastic:master Aug 20, 2021
@endorama endorama deleted the xpack-gcp-gke branch August 20, 2021 08:39
mergify bot pushed a commit that referenced this pull request Aug 20, 2021
Add a lightweight module to pull GCP GKE metrics.

Metrics are all GA metrics as of today available for Kubernetes on GCP.

Docs: cloud.google.com/monitoring/api/metrics_kubernetes
(cherry picked from commit 1140740)
mergify bot pushed a commit that referenced this pull request Aug 20, 2021
Add a lightweight module to pull GCP GKE metrics.

Metrics are all GA metrics as of today available for Kubernetes on GCP.

Docs: cloud.google.com/monitoring/api/metrics_kubernetes
(cherry picked from commit 1140740)
endorama added a commit that referenced this pull request Aug 20, 2021
Add a lightweight module to pull GCP GKE metrics.

Metrics are all GA metrics as of today available for Kubernetes on GCP.

Docs: cloud.google.com/monitoring/api/metrics_kubernetes
(cherry picked from commit 1140740)

Co-authored-by: endorama <526307+endorama@users.noreply.github.com>
endorama added a commit that referenced this pull request Aug 20, 2021
Co-authored-by: Edoardo Tenani <edoardo.tenani@elastic.co>
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Add a lightweight module to pull GCP GKE metrics.

Metrics are all GA metrics as of today available for Kubernetes on GCP.

Docs: cloud.google.com/monitoring/api/metrics_kubernetes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify enhancement Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Google Cloud] Add GKE integration
5 participants