datadog
by Spartan
Datadog Agent
About this chart
Spartan Datadog Helm Chart
NOTE: This chart adds the Datadog Agent deployment for APM only to reduce cost.
Datadog is a hosted infrastructure monitoring platform. This chart adds the Datadog Agent to all nodes in your cluster via a DaemonSet. It also optionally depends on the kube-state-metrics chart. For more information about monitoring Kubernetes with Datadog, please refer to the Datadog documentation website.
Datadog offers two variants, switch to a -jmx tag if you need to run JMX/java integrations. The chart also supports running the standalone dogstatsd image.
See the Datadog JMX integration to learn more.
How to use Spartan Datadog Helm repository
You need to add this repository to your Helm repositories:
helm repo add datadog https://spartan-stratos.github.io/helm-charts
helm repo update
Prerequisites
Kubernetes 1.10+ or OpenShift 3.10+, note that:
- the Datadog Agent supports Kubernetes 1.4+
- The Datadog chart's defaults are tailored to Kubernetes 1.10+, see Datadog Agent legacy Kubernetes versions documentation for adjustments you might need to make for older versions
Requirements
| Repository | Name | Version |
|---|---|---|
| https://helm.datadoghq.com | datadog-crds | 1.0.1 |
| https://prometheus-community.github.io/helm-charts | kube-state-metrics | 2.13.2 |
Quick start
By default, the Datadog Agent runs in a DaemonSet. It can alternatively run inside a Deployment for special use cases.
Note: simultaneous DaemonSet + Deployment installation within a single release will be deprecated in a future version, requiring two releases to achieve this.
Installing the Datadog Chart
To install the chart with the release name <RELEASE_NAME>, retrieve your Datadog API key from your Agent Installation Instructions and run:
helm install <RELEASE_NAME> \
--set datadog.apiKey=<DATADOG_API_KEY> spartan/datadog
By default, this Chart creates a Secret and puts an API key in that Secret.
However, you can use manually created secrets by setting the datadog.apiKeyExistingSecret and/or datadog.appKeyExistingSecret values (see Creating a Secret, below).
Note: When creating the secret(s), be sure to name the key fields api-key and app-key.
After a few minutes, you should see hosts and metrics being reported in Datadog.
Note: You can set your Datadog site using the datadog.site field.
helm install <RELEASE_NAME> \
--set datadog.appKey=<DATADOG_APP_KEY> \
--set datadog.site=<DATADOG_SITE> \
spartan/datadog
Create and provide a secret that contains your Datadog API and APP Keys
To create a secret that contains your Datadog API key, replace the <DATADOG_API_KEY> below with the API key for your organization. This secret is used in the manifest to deploy the Datadog Agent.
DATADOG_API_SECRET_NAME=datadog-api-secret
kubectl create secret generic $DATADOG_API_SECRET_NAME --from-literal api-key="<DATADOG_API_KEY>"
Note: This creates a secret in the default namespace. If you are in a custom namespace, update the namespace parameter of the command before running it.
Now, the installation command contains the reference to the secret.
helm install <RELEASE_NAME> \
--set datadog.apiKeyExistingSecret=$DATADOG_API_SECRET_NAME spartan/datadog
Enabling the Datadog Cluster Agent
The Datadog Cluster Agent is now enabled by default.
Read about the Datadog Cluster Agent in the official documentation.
Custom Metrics Server
If you plan to use the Custom Metrics Server feature, provide a secret for the application key (AppKey) using the datadog.appKeyExistingSecret chart variable.
DATADOG_APP_SECRET_NAME=datadog-app-secret
kubectl create secret generic $DATADOG_APP_SECRET_NAME --from-literal app-key="<DATADOG_APP_KEY>"
Note: the same secret can store the API and APP keys
DATADOG_SECRET_NAME=datadog-secret
kubectl create secret generic $DATADOG_SECRET_NAME --from-literal api-key="<DATADOG_API_KEY>" --from-literal app-key="<DATADOG_APP_KEY>"
Run the following if you want to deploy the chart with the Custom Metrics Server enabled in the Cluster Agent:
helm install datadog-monitoring \
--set datadog.apiKeyExistingSecret=$DATADOG_API_SECRET_NAME \
--set datadog.appKeyExistingSecret=$DATADOG_APP_SECRET_NAME \
--set clusterAgent.enabled=true \
--set clusterAgent.metricsProvider.enabled=true \
spartan/datadog
If you want to learn to use this feature, you can check out this Datadog Cluster Agent walkthrough.
The Leader Election is enabled by default in the chart for the Cluster Agent. Only the Cluster Agent(s) participate in the election, in case you have several replicas configured (using clusterAgent.replicas.
Cluster Agent Token
You can specify the Datadog Cluster Agent token used to secure the communication between the Cluster Agent(s) and the Agents with clusterAgent.token.
Uninstalling the Chart
To uninstall/delete the <RELEASE_NAME> deployment:
helm uninstall <RELEASE_NAME>
The command removes all the Kubernetes components associated with the chart and deletes the release.
Configuration
As a best practice, a YAML file that specifies the values for the chart parameters should be used to configure the chart. Any parameters not specified in this file will default to those set in values.yaml.
- Create an empty
datadog-values.yamlfile. - Create a Kubernetes
secretto store your Datadog API key and App key
kubectl create secret generic datadog-secret --from-literal api-key=$DD_API_KEY --from-literal app-key=$DD_APP_KEY
- Set the following parameters in your
datadog-values.yamlfile to reference the secret:
datadog:
apiKeyExistingSecret: datadog-secret
appKeyExistingSecret: datadog-secret
- Install or upgrade the Datadog Helm chart with the new
datadog-values.yamlfile:
helm install -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
OR
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
See the All configuration options section to discover all configuration possibilities in the Datadog chart.
Configuring Dogstatsd in the agent
The agent will start a server running Dogstatsd in order to process custom metrics sent from your applications. Check out the official documentation on Dogstatsd for more details.
By default the agent will create a unix domain socket to process the datagrams (not supported on Windows, see below).
To disable the socket in favor of the hostPort, use the following configuration:
datadog:
#(...)
dogstatsd:
useSocketVolume: false
useHostPort: true
Enabling APM and Tracing
APM is enabled by default using a socket for communication in the out-of-the-box values.yaml file; more details about application configuration are available on the official documentation.
Update your datadog-values.yaml file with the following configration to enable TCP communication using a hostPort:
datadog:
# (...)
apm:
portEnabled: true
To disable APM, set socketEnabled to false in your datadog-values.yaml file (portEnabled is false by default):
datadog:
# (...)
apm:
socketEnabled: false
Enabling APM Single Step Instrumentation (beta)
APM tracing libraries and configurations can be automatically injected in your application pods in the whole cluster or specific namespaces using Single Step Instrumentation.
Update your datadog-values.yaml file with the following configration to enable Single Step Instrumentation in the whole cluster:
datadog:
# (...)
apm:
instrumentation:
enabled: true
Single Step Instrumentation can be disabled in specific namespaces using configuration option disabledNamespaces:
datadog:
# (...)
apm:
instrumentation:
enabled: true
disabledNamespaces:
- namespaceA
- namespaceB
Single Step Instrumentation can be enabled in specific namespaces using configuration option enabledNamespaces:
datadog:
# (...)
apm:
instrumentation:
enabled: false
enabledNamespaces:
- namespaceC
To confiure the version of Tracing library that Single Step Instrumentation will instrument applications with, set the configuration libVersions:
datadog:
# (...)
apm:
instrumentation:
enabled: false
libVersions:
java: v1.18.0
python: v1.20.0
then upgrade your Datadog Helm chart:
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
Enabling Log Collection
Update your datadog-values.yaml file with the following log collection configuration:
datadog:
# (...)
logs:
enabled: true
containerCollectAll: true
then upgrade your Datadog Helm chart:
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
Enabling Process Collection
Update your datadog-values.yaml file with the process collection configuration:
datadog:
# (...)
processAgent:
enabled: true
processCollection: true
then upgrade your Datadog Helm chart:
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
Enabling NPM Collection
The system-probe agent only runs in dedicated container environment. Update your datadog-values.yaml file with the NPM collection configuration:
datadog:
# (...)
networkMonitoring:
# (...)
enabled: true
# (...)
then upgrade your Datadog Helm chart:
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
Kubernetes event collection
Use the Datadog Cluster Agent to collect Kubernetes events. Please read the official documentation for more context.
Alternatively set the datadog.leaderElection, datadog.collectEvents and rbac.create options to true in order to enable Kubernetes event collection.
conf.d and checks.d
The Datadog entrypoint copies files with a .yaml extension found in /conf.d and files with .py extension in /checks.d to /etc/datadog-agent/conf.d and /etc/datadog-agent/checks.d respectively.
The keys for datadog.confd and datadog.checksd should mirror the content found in their respective ConfigMaps. Update your datadog-values.yaml file with the check configurations:
datadog:
confd:
redisdb.yaml: |-
ad_identifiers:
- redis
- bitnami/redis
init_config:
instances:
- host: "%%host%%"
port: "%%port%%"
jmx.yaml: |-
ad_identifiers:
- openjdk
instance_config:
instances:
- host: "%%host%%"
port: "%%port_0%%"
redisdb.yaml: |-
init_config:
instances:
- host: "outside-k8s.example.com"
port: 6379
then upgrade your Datadog Helm chart:
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
For more details, please refer to the documentation.
Kubernetes Labels and Annotations
To map Kubernetes node labels and pod labels and annotations to Datadog tags, provide a dictionary with kubernetes labels/annotations as keys and Datadog tags key as values in your datadog-values.yaml file:
nodeLabelsAsTags:
beta.kubernetes.io/instance-type: aws_instance_type
kubernetes.io/role: kube_role
podAnnotationsAsTags:
iam.amazonaws.com/role: kube_iamrole
podLabelsAsTags:
app: kube_app
release: helm_release
then upgrade your Datadog Helm chart:
helm upgrade -f datadog-values.yaml <RELEASE_NAME> spartan/datadog
CRI integration
As of the version 6.6.0, the Datadog Agent supports collecting metrics from any container runtime interface used in your cluster. Configure the location path of the socket with datadog.criSocketPath; default is the Docker container runtime socket. To deactivate this support, you just need to unset the datadog.criSocketPath setting.
Standard paths are:
- Docker socket:
/var/run/docker.sock - Containerd socket:
/var/run/containerd/containerd.sock - Cri-o socket:
/var/run/crio/crio.sock
Configuration required for Amazon Linux 2 based nodes
Amazon Linux 2 does not support apparmor profile enforcement. Amazon Linux 2 is the default operating system for AWS Elastic Kubernetes Service (EKS) based clusters. Upda
Deploy datadog with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has datadog on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartdatadog is pinned at v0.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply