diff --git a/content/en/infrastructure/containers/configuration.md b/content/en/infrastructure/containers/configuration.md index a121b25c14a44..a4dfa3fa234da 100644 --- a/content/en/infrastructure/containers/configuration.md +++ b/content/en/infrastructure/containers/configuration.md @@ -411,7 +411,110 @@ field#status.conditions.HorizontalAbleToScale.status:"False"
You can select up to 50 fields per resource. You can use the preview to validate your indexing choices.
+### Collect custom resource metrics using Kubernetes State Core check + +
This functionality requires Cluster Agent 7.63.0+.
+ +You can use the `kubernetes_state_core` check to collect custom resource metrics when running the Datadog Cluster Agent. + +1. Write defintions for your custom resources and the fields to turn into metrics according to the following format: + + ```yaml + #=(...) + collectCrMetrics: + - groupVersionKind: + group: "crd.k8s.amazonaws.com" + kind: "ENIConfig" + version: "v1alpha1" + commonLabels: + crd_type: "eniconfig" + labelsFromPath: + crd_name: [metadata, name] + metrics: + - name: "eniconfig" + help: "ENI Config" + each: + type: gauge + gauge: + path: [metadata, generation] + - groupVersionKind: + group: "vpcresources.k8s.aws" + kind: "CNINode" + version: "v1alpha1" + resource: "cninode-pluralized" + commonLabels: + crd_type: "cninode" + labelsFromPath: + crd_name: [metadata, name] + metrics: + - name: "cninode" + help: "CNI Node" + each: + type: gauge + gauge: + path: [metadata, generation] + ``` + + For more details, see [Custom Resource State Metrics][5]. + +2. Update your Helm or Datadog Operator configuration: + {{< tabs >}} + {{% tab "Helm Chart" %}} + + 1. Add the following configuration to `datadog-values.yaml`: + + ```yaml + datadog: + #(...) + kubeStateMetricsCore: + collectCrMetrics: + - + ``` + + Replace `` with the definitions you wrote in the first step. + + 1. Upgrade your Helm chart: + + ``` + helm upgrade -f datadog-values.yaml datadog/datadog + ``` + + {{% /tab %}} + {{% tab "Datadog Operator" %}} + + 1. Install the Datadog Operator with an option that grants the Datadog Agent permission to collect custom resources: + + ``` + helm install datadog-operator datadog/datadog-operator --set clusterRole.allowReadAllResources=true + ``` + + 1. Add the following configuration to your `DatadogAgent` manifest, `datadog-agent.yaml`: + + ```yaml + apiVersion: datadoghq.com/v2alpha1 + kind: DatadogAgent + metadata: + name: datadog + spec: + #(...) + features: + kubeStateMetricsCore: + collectCrMetrics: + - + ``` + + Replace `` with the definitions you wrote in the first step. + + 1. Apply your new configuration: + + ``` + kubectl apply -n $DD_NAMESPACE -f datadog-agent.yaml + ``` + + {{% /tab %}} + {{< /tabs >}} + ## Further reading {{< partial name="whats-next/whats-next.html" >}} @@ -420,4 +523,4 @@ field#status.conditions.HorizontalAbleToScale.status:"False" [2]: /infrastructure/containers [3]: https://app.datadoghq.com/orchestration/explorer/pod [4]: https://app.datadoghq.com/orchestration/explorer/crd - +[5]: https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md