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 #16834 to 7.x: Fix k8s metadata issue #16976

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Mar 12, 2020

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

What does this PR do?

This PR fixes labels in k8s metadata. Issues found in 7.6 version: https://discuss.elastic.co/t/how-to-get-kubernetes-node-labels-with-metricbeat/220667/6

The proposed solution is to add kubernetes.labels.* in all resources (node, namespace etc) so as to cover cases like node metricset. Also when node, namespace, are part of other resources like pod then their labels are part of the sub-resource and not the main resource.

The proposed solution is to add kubernetes.labels.* in node resources so as to cover cases like node metricset. Also when node, is part of other resources like pod then their labels are part of the sub-resource and not the main resource.

Example with node as main resource :

{
    "node": {
        "name": "testnode",
        "uid":  "uid",
    },
    "labels": {
        "nodekey": "nodevalue",
    }
}

Example with sub-resources:

{
    "pod": {
        "name": "obj",
        "uid":  "uid",
    },
    "namespace": "default",
    "namespace_uid": "uid",
    "namespace_labels": {
            "nskey": "nsvalue",
    },
    "node": {
        "name": "testnode",
        "uid":  "uid",
        "labels": {
            "nodekey": "nodevalue",
        },
    },
    "labels": {
        "foo": "bar",
    },
    "annotations": {
        "app": "production",
    }
}

Why is it important?

Currently the metadata are not populated properly.

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

TBA

Related issues

@ChrsMark ChrsMark self-assigned this Mar 12, 2020
@ChrsMark ChrsMark added the Team:Platforms Label for the Integrations - Platforms team label Mar 12, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

looks good!

@ChrsMark ChrsMark merged commit 4ad2010 into elastic:7.x Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport review Team:Platforms Label for the Integrations - Platforms team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants