---
title: 'Quickstart: OpenTelemetry on Kubernetes'
description: >-
  Install OpenTelemetry on a Kubernetes cluster and send traces, metrics, and
  logs to Datadog.
breadcrumbs: >-
  Docs > OpenTelemetry in Datadog > Getting Started with OpenTelemetry at
  Datadog > Quickstart: OpenTelemetry on Kubernetes
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Quickstart: OpenTelemetry on Kubernetes

## Overview{% #overview %}

Monitor your Kubernetes applications and infrastructure in Datadog with OpenTelemetry. This quickstart installs a Collector, adds instrumentation to your application, and shows you where to find your services, traces, and logs in Datadog.

{% alert level="info" %}
For guided setup in Datadog, use [OpenTelemetry onboarding](https://app.datadoghq.com/signup/setup/plan/opentelemetry) in the app.
{% /alert %}

Use DDOT components, which Datadog recommends and which are in Preview, or upstream OpenTelemetry components. The installation steps are the same. Select your setup in the **DDOT** or **Upstream** tab in step 1. To compare the two, see [Choose a setup](https://docs.datadoghq.com/opentelemetry.md#choose-a-setup).

This quickstart runs on Kubernetes, and so does the DDOT Collector. On other platforms, use an upstream OpenTelemetry Collector or the Datadog Agent. See [Send OpenTelemetry Data to Datadog](https://docs.datadoghq.com/opentelemetry/setup.md).

## Prerequisites{% #prerequisites %}

- A Kubernetes cluster with cluster-admin access through `kubectl`.
- [Helm](https://helm.sh/docs/intro/install/) v4 or later, and `curl`.
- A [Datadog API key](https://docs.datadoghq.com/account_management/api-app-keys.md#api-keys).
- An application that runs in the cluster as a Deployment, written in Java, Python, Node.js, or .NET.

## 1. Set your configuration

Set these environment variables in the terminal you use for the rest of this quickstart:

{% tab title="DDOT" %}
**Note**: The DDOT SDKs and the DDOT Collector are in Preview.

```shell
export DD_API_KEY="<DATADOG_API_KEY>"
export DD_SITE="<DATADOG_SITE>"
export DD_INSTALL_FLOW=ddot
export K8S_CLUSTER_TYPE="<CLUSTER_TYPE>"
export K8S_CLUSTER_NAME="<CLUSTER_NAME>"
export DEPLOYMENT_ENVIRONMENT_NAME="<ENVIRONMENT>"
```

The installer also installs the Datadog Operator and the Datadog Agent in the `datadog` namespace. Datadog recommends running the Datadog Agent alongside DDOT for the Datadog-specific capabilities of DDOT SDKs, such as Live Debugger, Dynamic Instrumentation, and remotely configured sampling. The Datadog Agent acts mainly as a Remote Configuration proxy: your traces, metrics, and logs still go over OTLP to the Collector. See [Feature Compatibility](https://docs.datadoghq.com/opentelemetry/compatibility.md#feature-compatibility). To skip the Datadog Agent, also set `DD_AGENT_ENABLED=false`. Without it, those capabilities aren't available.

To also install the [Full-Host Profiler](https://docs.datadoghq.com/profiler/enabling/full_host.md) (Preview), set `DD_HOST_PROFILER_ENABLED=true`. It requires Linux nodes with kernel 5.10 or later and Kubernetes 1.30 or later.
{% /tab %}

{% tab title="Upstream" %}

```shell
export DD_API_KEY="<DATADOG_API_KEY>"
export DD_SITE="<DATADOG_SITE>"
export DD_INSTALL_FLOW=upstream
export K8S_CLUSTER_TYPE="<CLUSTER_TYPE>"
export K8S_CLUSTER_NAME="<CLUSTER_NAME>"
export DEPLOYMENT_ENVIRONMENT_NAME="<ENVIRONMENT>"
```

{% /tab %}

Replace the placeholders:

| Variable                      | Value                                                                                                                                                               |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DD_API_KEY`                  | Your Datadog API key.                                                                                                                                               |
| `DD_SITE`                     | The domain of your [Datadog site](https://docs.datadoghq.com/getting_started/site.md). For <YOUR_DATADOG_DATACENTER>, it's <YOUR_DATADOG_SITE>.                     |
| `K8S_CLUSTER_TYPE`            | `eks`, `gcp`, `aks`, or `other`. For `eks`, `gcp`, and `aks`, the Collectors detect the cluster name, so you can leave out `K8S_CLUSTER_NAME`.                      |
| `K8S_CLUSTER_NAME`            | Set it when `K8S_CLUSTER_TYPE` is `other`. A name for your Kubernetes cluster, in lowercase letters, numbers, and hyphens. Datadog shows it in Kubernetes Explorer. |
| `DEPLOYMENT_ENVIRONMENT_NAME` | The `env` tag for all your data, such as `staging`, in lowercase letters, numbers, and hyphens. If you leave it out, the installer uses `production`.               |

## 2. Run the installer

1. Run the installer:

   ```shell
   DD_INSTALL_SOURCE=docs bash -c "$(curl -fsSL https://raw.githubusercontent.com/DataDog/opentelemetry-examples/v0.1.0/guides/kubernetes/configuration/opentelemetry-kube-stack/install)"
   ```

1. Wait for the OpenTelemetry Operator to be ready, then list the pods. The OpenTelemetry Operator only instruments pods that start after it's ready.

   ```shell
   kubectl rollout status deployment/opentelemetry-kube-stack-opentelemetry-operator -n opentelemetry-operator-system --timeout=5m
   kubectl get pods -n opentelemetry-operator-system
   ```

Within a minute or two, these pods are `Running`: the OpenTelemetry Operator, kube-state-metrics, the `cluster` Collector, and one `daemon` Collector for each node.

## 3. Instrument your application

On the DDOT path, if your application already includes an SDK, see [Adapt an existing deployment](https://github.com/DataDog/opentelemetry-examples/blob/v0.1.0/guides/kubernetes/configuration/opentelemetry-kube-stack/ddot/ADAPT-EXISTING-CONFIG.md) before you add the annotation.

1. Add the language annotation to your Deployment's pod template. Replace `<DEPLOYMENT_NAME>` and `<NAMESPACE>` with your Deployment's name and namespace, and `<LANGUAGE>` with `java`, `python`, `nodejs`, or `dotnet`:

   ```shell
   kubectl patch deployment <DEPLOYMENT_NAME> -n <NAMESPACE> --type merge -p '{"spec":{"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-<LANGUAGE>":"opentelemetry-operator-system/opentelemetry-kube-stack"}}}}}'
   kubectl rollout status deployment/<DEPLOYMENT_NAME> -n <NAMESPACE> --timeout=5m
   ```

The patch restarts the pods with instrumentation: the DDOT SDK on the DDOT path, or the upstream OpenTelemetry SDK on the Upstream path. The second command waits for the restart to finish. The SDK sends data to the `daemon` Collector, so you don't need to set an endpoint.

1. Send a few requests to your application so it produces traces.

## 4. Verify your data in Datadog

Data appears within a few minutes. `<SERVICE_NAME>` is your Deployment's name, unless you set a different service name. `<ENVIRONMENT>` is the value you set in step 1.

| Check    | Where to look                                                                                                          | What you see                                          |
| -------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| Services | [Catalog](https://app.datadoghq.com/software): set the environment to `<ENVIRONMENT>` and search for `<SERVICE_NAME>`. | The service page, with requests, errors, and latency. |
| Traces   | [Trace Explorer](https://app.datadoghq.com/apm/traces): search for `service:<SERVICE_NAME> env:<ENVIRONMENT>`.         | Traces you can open to see their spans.               |
| Logs     | [Log Explorer](https://app.datadoghq.com/logs): search for `service:<SERVICE_NAME> env:<ENVIRONMENT>`.                 | Your application's logs.                              |

## Troubleshooting{% #troubleshooting %}

### No data in Datadog{% #no-data-in-datadog %}

Check that `DD_SITE` matches your Datadog site and that your API key is valid. Search the `daemon` Collector's logs for export errors:

```shell
kubectl logs -n opentelemetry-operator-system daemonset/opentelemetry-kube-stack-daemon-collector | grep -iE "403|401|forbidden|exporting failed"
```

A `403` or `401` usually means the API key or the site is wrong.

### Your service doesn't appear{% #your-service-doesnt-appear %}

Check that the annotation names your application's language. If it does, the pods probably started before the OpenTelemetry Operator was ready. Restart the Deployment so its pods start with instrumentation:

```shell
kubectl rollout restart deployment <DEPLOYMENT_NAME> -n <NAMESPACE>
```

For more help, see [OpenTelemetry Troubleshooting](https://docs.datadoghq.com/opentelemetry/troubleshooting.md).

## Change your configuration{% #change-your-configuration %}

The installer installs the [OpenTelemetry Kube Stack](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-kube-stack) Helm chart with its own values files. To change the configuration, put your changes in a values file. Then, with the variables from step 1 set, run the installer again from the folder that contains your file:

```shell
DD_INSTALL_SOURCE=docs bash -c "$(curl -fsSL https://raw.githubusercontent.com/DataDog/opentelemetry-examples/v0.1.0/guides/kubernetes/configuration/opentelemetry-kube-stack/install)" install my-values.yaml
```

The installer applies your file on top of its own values files. For what you can set, see the [installer's README](https://github.com/DataDog/opentelemetry-examples/tree/v0.1.0/guides/kubernetes/configuration/opentelemetry-kube-stack#readme).

## Next steps{% #next-steps %}

- **Instrument more services**: Annotate their Deployments as in step 3. To add custom spans and metrics, see [Instrument Your Applications](https://docs.datadoghq.com/opentelemetry/instrument.md).
- **Tag your data**: Learn how Datadog uses `service.name`, `deployment.environment.name`, and `service.version` in [Unified service tagging](https://docs.datadoghq.com/opentelemetry/correlate.md#prerequisite-unified-service-tagging).
- **Manage the Collector yourself (optional)**: To install and manage the Collector with your own Helm charts or OpenTelemetry Operator configuration instead of the installer, see [Install the DDOT Collector on Kubernetes](https://docs.datadoghq.com/opentelemetry/setup/ddot_collector/kubernetes.md) or [Set up the upstream OpenTelemetry Collector](https://docs.datadoghq.com/opentelemetry/setup/collector_exporter.md?tab=kubernetes).

## Uninstall{% #uninstall %}

{% alert level="warning" %}
The uninstall script deletes the `opentelemetry-operator-system`, `cert-manager`, and `datadog` namespaces. It also deletes the custom resource definitions for cert-manager, the OpenTelemetry Operator, and the Datadog Operator. That removes every matching resource in the cluster, including resources that other tools created, such as a Datadog Agent you installed separately.
{% /alert %}

1. Remove the annotation from your Deployment. Its pods restart without instrumentation:

   ```shell
   kubectl patch deployment <DEPLOYMENT_NAME> -n <NAMESPACE> --type json -p '[{"op":"remove","path":"/spec/template/metadata/annotations/instrumentation.opentelemetry.io~1inject-<LANGUAGE>"}]'
   ```

1. Run the uninstall script, and type `yes` when it asks:

   ```shell
   bash -c "$(curl -fsSL https://raw.githubusercontent.com/DataDog/opentelemetry-examples/v0.1.0/guides/kubernetes/configuration/opentelemetry-kube-stack/uninstall)"
   ```

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Correlate OpenTelemetry Data](https://docs.datadoghq.com/opentelemetry/correlate.md)
- [Hostname and Tagging](https://docs.datadoghq.com/opentelemetry/config/hostname_tagging.md)
- [Datadog and OpenTelemetry Compatibility](https://docs.datadoghq.com/opentelemetry/compatibility.md)
