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

Enrich k8s state service events & add selector meta #23730

Merged
merged 6 commits into from
Feb 2, 2021

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Jan 28, 2021

What does this PR do?

  1. adds metadata enricher on state_service metrics so as to enrich metrics with Service objects metadata.
  2. make use of ServiceMetadataGenerator to enrich Service related events and not the generic ResourceMetadataGenerator
  3. Improves ServiceMetadataGenerator so as to include selector information (if exist) for a Service object.

Note that with this implementation selector's key:val maps are added similarly with labels like kubernetes.service.selectors.* but we can add them differently if Metrics UI requires that, @sorantis just let me know what you think.

Why is it important?

So as to properly enrich state_service events with Service metadata and include selector information in these metadata.

Example:

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376

This service will be enriched with kubernetes.service.selectors.app: MyApp which will give us to the option to correlate the service with all the pods that are selected/exposed by this service and are labeled with kubernetes.labels.app: MyApp.

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.

How to test this PR locally

  1. Deploy Metricbeat on k8s to collect metrics from kube_state_metrics and specifically using state_service metricset.
  2. Ensure that metadata are included (ie labels) as well as selector information.

Related issues

Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark added enhancement review needs_backport PR is waiting to be backported to other branches. Team:Integrations Label for the Integrations team needs_reviewer PR needs to be assigned a reviewer v7.12.0 kubernetes Enable builds in the CI for kubernetes labels Jan 28, 2021
@ChrsMark ChrsMark self-assigned this Jan 28, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jan 28, 2021
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark requested a review from a team as a code owner January 28, 2021 13:04
@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 #23730 event

    • Start Time: 2021-02-01T08:09:39.533+0000
  • Duration: 50 min 33 sec

  • Commit: 55fc231

Test stats 🧪

Test Results
Failed 0
Passed 44578
Skipped 4612
Total 49190

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 44578
Skipped 4612
Total 49190

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Nice 👍

@ChrsMark ChrsMark merged commit 1f38fff into elastic:master Feb 2, 2021
@ChrsMark ChrsMark added the test-plan Add this PR to be manual test plan label Feb 2, 2021
ChrsMark added a commit to ChrsMark/beats that referenced this pull request Feb 2, 2021
@ChrsMark ChrsMark removed the needs_backport PR is waiting to be backported to other branches. label Feb 2, 2021
ChrsMark added a commit that referenced this pull request Feb 2, 2021
@andresrc andresrc added the test-plan-added This PR has been added to the test plan label Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement kubernetes Enable builds in the CI for kubernetes needs_reviewer PR needs to be assigned a reviewer review Team:Integrations Label for the Integrations team test-plan Add this PR to be manual test plan test-plan-added This PR has been added to the test plan v7.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enrich Kubernetes Service metadata with ServiceMetadataGenerator
4 participants