Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion content/en/infrastructure/containers/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,110 @@

<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>

### Collect custom resource metrics using Kubernetes State Core check

Check warning on line 414 in content/en/infrastructure/containers/configuration.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.headings

'Collect custom resource metrics using Kubernetes State Core check' should use sentence-style capitalization.

<div class="alert alert-info">This functionality requires Cluster Agent 7.63.0+.</div>

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"
Copy link
Member

Choose a reason for hiding this comment

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

It is not clear in this doc that this would result in a metric named (I am assuming) kubernetes_state_customresource.eniconfig

The kubernetes_state_customresource prefix behavior should be called out somewhere in this doc

Likewise, the behavior when the a metricNamePrefix is specified should also be documented (it would result in a metric like kubernetes_state_customresource.<metricNamePrefix>_<metricName>

help: "ENI Config"
each:
type: gauge
gauge:
path: [metadata, generation]
- groupVersionKind:
group: "vpcresources.k8s.aws"
kind: "CNINode"
version: "v1alpha1"
resource: "cninode-pluralized"
Copy link
Member

Choose a reason for hiding this comment

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

What this field is / why it is needed / when it is needed could be explicitly called out somewhere here

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:
- <CUSTOM_RESOURCE_METRIC>
```

Replace `<CUSTOM_RESOURCE_METRIC>` with the definitions you wrote in the first step.

1. Upgrade your Helm chart:

```
helm upgrade -f datadog-values.yaml <RELEASE_NAME> datadog/datadog
```

{{% /tab %}}
{{% tab "Datadog Operator" %}}

1. Install the Datadog Operator with an option that grants the Datadog Agent permission to collect custom resources:
Copy link
Member

Choose a reason for hiding this comment

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

This should be updated to signify that it requires operator v1.20+


```
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:
- <CUSTOM_RESOURCE_METRIC>
```

Replace `<CUSTOM_RESOURCE_METRIC>` 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" >}}
Expand All @@ -420,4 +523,4 @@
[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
Loading