Skip to content

Commit fca36bb

Browse files
bitomaxspcswatt
andauthored
Add KSM CR metrics (#32716)
* Add KSM CR metrics * Fixes after review * Update configuration.md --------- Co-authored-by: cecilia saixue wat-kim <cecilia.watt@datadoghq.com>
1 parent 507f6fd commit fca36bb

File tree

1 file changed

+104
-1
lines changed

1 file changed

+104
-1
lines changed

content/en/infrastructure/containers/configuration.md

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,110 @@ field#status.conditions.HorizontalAbleToScale.status:"False"
411411

412412
<div class="alert alert-info">You can select up to 50 fields per resource. You can use the preview to validate your indexing choices.</div>
413413

414+
### Collect custom resource metrics using Kubernetes State Core check
415+
416+
<div class="alert alert-info">This functionality requires Cluster Agent 7.63.0+.</div>
417+
418+
You can use the `kubernetes_state_core` check to collect custom resource metrics when running the Datadog Cluster Agent.
419+
420+
1. Write defintions for your custom resources and the fields to turn into metrics according to the following format:
421+
422+
```yaml
423+
#=(...)
424+
collectCrMetrics:
425+
- groupVersionKind:
426+
group: "crd.k8s.amazonaws.com"
427+
kind: "ENIConfig"
428+
version: "v1alpha1"
429+
commonLabels:
430+
crd_type: "eniconfig"
431+
labelsFromPath:
432+
crd_name: [metadata, name]
433+
metrics:
434+
- name: "eniconfig"
435+
help: "ENI Config"
436+
each:
437+
type: gauge
438+
gauge:
439+
path: [metadata, generation]
440+
- groupVersionKind:
441+
group: "vpcresources.k8s.aws"
442+
kind: "CNINode"
443+
version: "v1alpha1"
444+
resource: "cninode-pluralized"
445+
commonLabels:
446+
crd_type: "cninode"
447+
labelsFromPath:
448+
crd_name: [metadata, name]
449+
metrics:
450+
- name: "cninode"
451+
help: "CNI Node"
452+
each:
453+
type: gauge
454+
gauge:
455+
path: [metadata, generation]
456+
```
457+
458+
For more details, see [Custom Resource State Metrics][5].
459+
460+
2. Update your Helm or Datadog Operator configuration:
414461

462+
{{< tabs >}}
463+
{{% tab "Helm Chart" %}}
464+
465+
1. Add the following configuration to `datadog-values.yaml`:
466+
467+
```yaml
468+
datadog:
469+
#(...)
470+
kubeStateMetricsCore:
471+
collectCrMetrics:
472+
- <CUSTOM_RESOURCE_METRIC>
473+
```
474+
475+
Replace `<CUSTOM_RESOURCE_METRIC>` with the definitions you wrote in the first step.
476+
477+
1. Upgrade your Helm chart:
478+
479+
```
480+
helm upgrade -f datadog-values.yaml <RELEASE_NAME> datadog/datadog
481+
```
482+
483+
{{% /tab %}}
484+
{{% tab "Datadog Operator" %}}
485+
486+
1. Install the Datadog Operator with an option that grants the Datadog Agent permission to collect custom resources:
487+
488+
```
489+
helm install datadog-operator datadog/datadog-operator --set clusterRole.allowReadAllResources=true
490+
```
491+
492+
1. Add the following configuration to your `DatadogAgent` manifest, `datadog-agent.yaml`:
493+
494+
```yaml
495+
apiVersion: datadoghq.com/v2alpha1
496+
kind: DatadogAgent
497+
metadata:
498+
name: datadog
499+
spec:
500+
#(...)
501+
features:
502+
kubeStateMetricsCore:
503+
collectCrMetrics:
504+
- <CUSTOM_RESOURCE_METRIC>
505+
```
506+
507+
Replace `<CUSTOM_RESOURCE_METRIC>` with the definitions you wrote in the first step.
508+
509+
1. Apply your new configuration:
510+
511+
```
512+
kubectl apply -n $DD_NAMESPACE -f datadog-agent.yaml
513+
```
514+
515+
{{% /tab %}}
516+
{{< /tabs >}}
517+
415518
## Further reading
416519

417520
{{< partial name="whats-next/whats-next.html" >}}
@@ -420,4 +523,4 @@ field#status.conditions.HorizontalAbleToScale.status:"False"
420523
[2]: /infrastructure/containers
421524
[3]: https://app.datadoghq.com/orchestration/explorer/pod
422525
[4]: https://app.datadoghq.com/orchestration/explorer/crd
423-
526+
[5]: https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md

0 commit comments

Comments
 (0)