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

Cherry-pick #25640 to 7.x: Refactor state_* metricsets to share response from endpoint #25759

Merged
merged 1 commit into from
May 18, 2021

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented May 18, 2021

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

What does this PR do?

This PR changes how kubernetes module handle state_* metricsets which share same target endpoint. The idea originates from https://github.com/elastic/beats/blob/master/x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go

Note: At this point the PR stands more like a PoC with changes only applied at state_container and state_pod metricsets.

If we agree with this solution (and make sure that it would be applied with Agent too) we can extend it to the rest of state_* metricsets as well as to metricsets fetch from kubelet's endpoint (node, pod, container, volume, system)

In upcoming PR we will apply similar strategy for metricsets fetching from kubelet's endpoint (node, pod, container, volume, system)

Why is it important?

To improve the performance of the module by avoid fetching same content multiple times.

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

  • Does it have impact for Agent deployments too?
    Verified with different module's config blocks. See step 4 of testing notes below.

How to test this PR locally

  1. On a k8s cluster install kube_state_metrics (https://github.com/kubernetes/kube-state-metrics/tree/master/examples/standard)
  2. Expose kube_state_metrics endpoint on the local machine -> kubectl -n kube-system port-forward svc/kube-state-metrics 8081:8080
  3. Start capturing traffic on kube-state-metrics' endpoint -> tcpdump -i any -s 0 'tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'
  4. Test with different module's config blocks (what Agent does):
- module: kubernetes
  metricsets:
    - state_pod
  period: 10s
  hosts: ["0.0.0.0:8081"]
  add_metadata: false

- module: kubernetes
metricsets:
- state_container
period: 10s
hosts: ["0.0.0.0:8081"]
add_metadata: false

Verify with tcpdump's output that only one request takes place no matter how many modules/metricsets are enabled.

  1. Test one combined module block:
- module: kubernetes
  metricsets:
    - state_pod
    - state_container
  period: 10s
  hosts: ["0.0.0.0:8081"]
  add_metadata: false

Verify with tcpdump's output that only one request takes place no matter how many modules/metricsets are enabled.

Related issues

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

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 18, 2021
@elasticmachine
Copy link
Collaborator

💚 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

Expand to view the summary

Build stats

  • Build Cause: Pull request #25759 opened

  • Start Time: 2021-05-18T13:25:20.859+0000

  • Duration: 90 min 21 sec

  • Commit: e6fb195

Test stats 🧪

Test Results
Failed 0
Passed 8308
Skipped 2261
Total 10569

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 8308
Skipped 2261
Total 10569

@ChrsMark ChrsMark merged commit 13f98a4 into elastic:7.x May 18, 2021
@zube zube bot removed the [zube]: Done label Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants