integrations-core icon indicating copy to clipboard operation
integrations-core copied to clipboard

Pod/Deployment Labels to Kube_State_Metrics

Open midN opened this issue 7 years ago • 12 comments

Currently, Kube_State_Metrics collected by Datadog are basic metrics without additional labels.

Most of those metrics are extremely simple and limited to labels such as Name and Deployment.

As a result, it's impossible to filter out in Dashboards nor Monitoring some Deployments/Daemonsets based on extra Labels. And that's despite Agent having an option to provide "DD_KUBERNETES_POD_LABELS_AS_TAGS" environment variable. Provided tags in ENV variable are only applied to metrics collected directly from Kubernetes API.


Solution: Parse ignored INFO metrics containing extra labels per deployment/pod/daemonset - https://github.com/DataDog/integrations-core/blob/301111499c051fa1f4c7d783b3eae8568429ab97/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py#L185

And add those as tags to original metrics.


FYI: You can do so in Prometheus by grouping Pod metrics with PodInfo metrics for example. Examples of doing so are in kube-state-metrics repo.

midN avatar Apr 05 '19 19:04 midN

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

stale[bot] avatar May 05 '19 19:05 stale[bot]

@stale not my fault yo!

midN avatar May 06 '19 11:05 midN

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

stale[bot] avatar Jun 05 '19 12:06 stale[bot]

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

sudo unstale!

midN avatar Jun 06 '19 17:06 midN

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

stale[bot] avatar Jul 06 '19 18:07 stale[bot]

See also DataDog/datadog-agent#2671

ellieayla avatar Jul 08 '19 16:07 ellieayla

Hi @midN,

Thanks for opening this issue. If the labels are on this metric kube_pod_labels, you could get them with a join in the kubernetes_state check configuration (by mounting a configmap https://docs.datadoghq.com/agent/kubernetes/integrations/#configmap):

label_joins:
      kube_pod_labels:
        label_to_match: pod
        labels_to_get:
         - ...

As explained in DataDog/datadog-agent#2671 thanks @alanjcastonguay for referencing it.

You can use join on an ignored metric, as we do it in the check: https://github.com/DataDog/integrations-core/blob/master/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py#L243

Let me know if this works for you!

Simon

Simwar avatar Jul 17 '19 15:07 Simwar

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

stale[bot] avatar Aug 16 '19 15:08 stale[bot]

Hi all,

Thanks for the detailed description.

@Simwar 's answer should work but is more manual than what we intend for the product. We know the tagging is not consistent between kube-state-metrics and the rest of the integrations. We're planning on tackling that asap. If you need this urgently, feel free to reach out to support to place a feature request with them, or if you have time, to submit a PR which we'll be happy to review.

Thanks again

hkaj avatar Sep 25 '19 14:09 hkaj

@hkaj is there a plan to fix the integration with kube-state-metrics? currently majority of the labels don't have proper secondary tags, which make it very hard to build charts

zbutt-muvaki avatar Oct 07 '19 04:10 zbutt-muvaki

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

stale[bot] avatar Nov 06 '19 05:11 stale[bot]

Hi @zbutt-muvaki Yes, we're working on several things in this area. I think you'd be interested in this PR: https://github.com/DataDog/integrations-core/pull/5650

We also have other work in flight wrt kube-state-metrics to improve tagging, check run time, and resource usage. I don't have a public timeline yet, but it's on our plate.

hkaj avatar Feb 12 '20 18:02 hkaj