> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamnative.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure Datadog

StreamNative Platform integrates with [Datadog](https://www.datadoghq.com/), which you can use to collect metrics for the following components and send the metrics to Datadog.

* ZooKeeper
* BookKeeper
* Pulsar broker
* Pulsar proxy
* Vault
* Prometheus

By default, Datadog collection annotation is disabled on StreamNative Platform. To enable it, you can set `monitoring.datadog` to `true` in the `values.yaml` YAML file. StreamNative Platform allows you to configure Datadog for the components that it deploys. You can enable or disable Datadog collection annotation for components in the `values.yaml` YAML file.

```yaml theme={null}
monitoring:
  datadog: true # --- [1]
datadog:
  namespace: {} # --- [2]
  component: datadog
  components:
    zookeeper: # --- [3]
      enabled: true # --- [4]
      metrics: # --- [5]
        ['"_*"']
```

* \[1] `datadog`: enable or disable Datadog collection annotation on StreamNative Platform. By default, Datadog collection annotation is disabled.
* \[2] `namespace`: specify the Datadog `<METRICS_NAMESPACE_PREFIX_FOR_DATADOG>` configuration. You can set the namespace to be prefixed to every metric when viewed in Datadog. By default, it is set to the namespace where the `sn-platform` chart is installed.
* \[3] `<component>`: specify the component that you want Datadog to collect metrics for. Currently, you can use Datadog to collect metrics for the ZooKeeper, BookKeeper, Pulsar broker, Pulsar proxy, Vault, and Prometheus.
* \[4] `enabled`: enable or disable Datadog collection annotation for the specific component. If enabled, you can use Datadog to collect metrics for the specific component.
* \[5] `metrics`: specify the metrics to be collected. By default, all metrics (`"\"_*\""`) are collected. For a list of supported metrics, see [Pulsar metrics](https://pulsar.apache.org/docs/reference-metrics) and [Vault metrics](https://developer.hashicorp.com/vault/tutorials/monitoring/telemetry-metrics-reference).

## Enable Datadog collection annotation

This section describes how to enable Datadog collection annotation on StreamNative Platform to collect metrics.

### Prerequisites

* Install Datadog Agent. For details, see [Getting Started with the Agent](https://docs.datadoghq.com/getting_started/agent/).
* Configure the Datadog Agent with an authentication token.

<Note title="Note">
  This prerequisite only applies to enabling Datadog collection annotation for the Pulsar proxy.
</Note>

1. Get the token that is used to access your Pulsar proxy.

   ```bash theme={null}
   kubectl get secret <release_name>-token-admin -o=jsonpath='{.data.TOKEN}' -n <k8s_namespace> | base64 --decode; echo
   ```

2. Configure the `PROXY_TOKEN` as an environment variable on your Datadog Agent.

   ```yaml theme={null}
   agents:
     containers:
       agent:
         env:
           - name: DD_PROXY_TOKEN
             value: <PROXY_TOKEN>
   ```

### Steps

This section describes how to enable Datadog collection annotation on StreamNative Platform.

<Tabs>
  <Tab title="Enable Datadog collection annotation for Pulsar components">
    This section describes how to enable Datadog collection annotation on StreamNative Platform to collect metrics for Pulsar components.

    1. Enable Datadog collection annotation.

       This example shows how to enable Datadog collection annotation to collect metrics for the ZooKeeper cluster.

       ```yaml theme={null}
       monitoring:
         datadog: true
       datadog:
         namespace: {}
         component: datadog
         components:
           zookeeper:
             enabled: true
             metrics: ['"_*"']
       ```

    2. Apply the new configuration.

       ```bash theme={null}
       helm upgrade -f /path/to/your/values.yaml <release_name> streamnative/sn-platform -n <k8s_namespace>
       ```
  </Tab>

  <Tab title="Enable Datadog collection annotation for Vault">
    This section describes how to enable Datadog collection annotation to collect the Vault performance data.

    1. Enable Datadog collection annotation for the Vault cluster.

       ```yaml theme={null}
       monitoring:
         datadog: true
       datadog:
         namespace: {}
         component: datadog
         components:
           vault:
             enabled: true
             auth:
               enabled: false
               token: ''
             tags: {}
       ```

    <Note title="Note">
      To ensure Vault check work properly, you need to either enable unauthenticated access to Vault metrics or provide a Vault token:
    </Note>

    > * To enable unauthenticated access, set `datadog.components.vault.auth.enabled` to `false`.
    > * To use a Vault token, set `datadog.components.vault.auth.enabled` to `true` and provide the Vault token. For details about how to get a Vault token, see the [prepare to connect to a Pulsar cluster](/private-cloud/v1/build/connect-prepare) user guide.

    2. Apply the new configuration.

       ```bash theme={null}
       helm upgrade -f /path/to/your/values.yaml <release_name> streamnative/sn-platform -n <k8s_namespace>
       ```
  </Tab>
</Tabs>
