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

# Datadog

> The Datadog extension allows you to receive real-time metrics and events about your syncs

## Overview

Hightouch integrates with Datadog to help you gain greater observability into your syncs and monitor their health. Once you've authorized access to Datadog in Hightouch, we send real-time sync metrics and events to your Datadog account. You can then aggregate these statistics to gain insight into the health of your syncs.

## Setup

You need your [Datadog site](https://docs.datadoghq.com/getting_started/site/) and [API key](https://docs.datadoghq.com/account_management/api-app-keys/) to set up the extension. You may want to create a new API key for Hightouch. Make sure that the API key creator in Datadog has the necessary write permissions for [custom metrics](https://docs.datadoghq.com/metrics/custom_metrics/) (`Metric Tags Write`, `Host Tags Write`, `Metrics Metadata Write`) and [events](https://docs.datadoghq.com/events/) (`Event Config Write`).

> [!WARNING]
>
> Make sure to use the **API Key** itself and not the Key ID. Also ensure you use an API Key and not an Application Key to avoid the `Datadog configuration is invalid` error. You can find more information about the difference between these keys in [Datadog's documentation](https://docs.datadoghq.com/account_management/api-app-keys/).

1. Go to the [**Monitoring** section](https://app.hightouch.com/extensions/monitoring?from=docs) of the **Extensions** page and select **Configure extension**.
2. Select your Datadog [**site**](https://docs.datadoghq.com/getting_started/site/) and enter your **API Key**.
3. Click **Save**.

Once you've saved your Datadog credentials in Hightouch, your syncs automatically start emitting metrics and events to Datadog.

> [!NOTE]
>
> Hightouch metrics and events don't immediately show up in Datadog, but only once sync runs are triggered.

## Emitted metrics and events

Hightouch emits both [metrics](https://docs.datadoghq.com/metrics/types/) and [events](https://docs.datadoghq.com/events/). Metrics are best suited for dashboards and statistical aggregations, while events are best for filtering. Don't hesitate to [get in touch](#pylon-chat) if there's another metric or event you're interested in using.

### Metrics

#### `hightouch.sync.row_processed`

This metric is a [`COUNT`](https://docs.datadoghq.com/metrics/types/?tab=count) type metric and is incremented for each row processed in the sync.

It provides the following tags:

* `sync` - The sync slug in Hightouch.
* `workspace` - The slug of the Hightouch workspace that contains the sync.
* `op` (added/changed/removed) - The operation performed: whether the row was added, changed, or removed in the query.
* `success` (true/false) - Whether the row was successfully synced to the destination.

#### `hightouch.sync.complete`

This metric is a [`COUNT`](https://docs.datadoghq.com/metrics/types/?tab=count) type metric and is incremented each time the sync completes.

It supports the following tags:

* `sync` - The sync slug in Hightouch.
* `workspace` - The slug of the Hightouch workspace that contains the sync.
* `status` (success/failed/warning/cancelled) - The overall status of the sync run.

#### `hightouch.sync.query_time`

This metric tracks your syncs' querying times.

It supports the following tags:

* `sync` - The sync slug in Hightouch.
* `workspace` - The slug of the Hightouch workspace that contains the sync.

#### `hightouch.sync.execution_time`

This metric tracks your syncs' execution times.

It supports the following tags:

* `sync` - The sync slug in Hightouch.
* `workspace` - The slug of the Hightouch workspace that contains the sync.

#### `hightouch.sync.total_time`

This metric tracks your syncs' total run times.

It supports the following tags:

* `sync` - The sync slug in Hightouch.
* `workspace` - The slug of the Hightouch workspace that contains the sync.

### Events

#### `hightouch.sync.complete`

Hightouch emits this event each time a sync completes. It's identical to the metric of the same name.

It supports the following tags:

* `sync` - The sync slug in Hightouch.
* `workspace` - The slug of the Hightouch workspace that contains the sync.
* `status` (success/failed/warning/canceled) - The overall status of the sync run.

## Use cases

With just a few metrics, you can build complex dashboards and monitors. For example, you can create dashboards that target specific syncs that are critical to your operations and report the total number of operations or top syncs that have warnings or failures.

![Example Datadog dashboard](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/integrations/datadog-metrics-dashboard.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=28c37b76e74aa90947a9e8a9a021f765)

You can [import the JSON](https://docs.datadoghq.com/dashboards/#copy-import-or-export-dashboard-json) for a basic dashboard using this [sample code](https://gist.github.com/PedramNavid/71f73c98d98373053674f19b8239b06c) to get started.

### Completed sync status

One common use case is to build a basic dashboard that tracks completed syncs by status over time.

![Datadog sync dashboard](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/integrations/datadog-metrics-sync.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=36181a5d682cfa40340e7ba9dc71f399)

The preceding chart uses the [`hightouch.sync.complete` metric](#hightouchsynccomplete) and sums the counts by `status`. You can filter further by including only statuses that are `status:success` or `NOT status:success`.

### Anomaly detection

Anomaly detection can help flag significant changes, like many users suddenly being deleted or created. You can use the Datadog extension for anomaly detection in added, changed, or removed rows.

#### Anomaly detection setup

1. In Datadog, create a [metric monitor](https://docs.datadoghq.com/monitors/create/types/metric/) with the **Anomaly Detection** method.

![Datadog metric monitor configuration](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/integrations/datadog-anamoly-detection-method.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=8525f14637eed2bd6da33ada7388cbfa)

2. Define the metric by selecting the [`hightouch.sync.row_processed`](##hightouchsyncrow_processed) metric. Specify the `op_type`, for example, `removed`, and `sync` name. Select the metric aggregation as `sum by` and enter `sync`.

![Datadog metric monitor configuration with sum by sync](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/integrations/datadog-sum-by-sync.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=0e926c1cd18febe0524ebd47d0efba20)

3. In [**Alert Conditions**](https://docs.datadoghq.com/monitors/create/types/metric/?tab=threshold#set-alert-conditions), set the **Alert threshold** and **Warning threshold** to values that make sense for your use case.

![Datadog metric monitor configuration](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/integrations/datadog-alert-conditions.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=cbba9caf52f5d78d79fa3d02335b16b6)

4. (Optional) You can inject the sync name into the monitor's subject or message body using `{{sync.name}}`.

![Datadog metric monitor configuration with sum by sync](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/integrations/datadog-notification.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=3909bb004e8eb471ee5dcd28635b3e39)

### Other use cases

You're not limited to the preceding examples. Here are some other use cases to consider:

* Metric monitors for when the number of failed rows exceeds a threshold
* Metric monitors for when a critical sync hasn't run over a specified time period
