Atlas Datadog API Integration

This guide will help you configure Atlas to authenticate and proxy HTTP requests to the Datadog API.

Datadog is an observability, monitoring, and security platform.

The Datadog API provides developers with programmatic access to the Datadog platform. Datadog collects metrics, logs, and events from a wide range of sources, and uses that data to power a suite of products like APM, security monitoring, log management, and alerting.

At the end of this guide, your running instance of Atlas will be configured to:

  • Proxy HTTP requests to the Datadog API.

  • Authenticate these requests using one or more Datadog API keys.

Availability

Public beta. This integration is available to all Atlas users, but the API may change.

Prerequisites

Provision a Datadog API key and a Datadog Application key

Programmatically accessing the Datadog API requires both an API key and an Application key.

An API key identifies your organization to the Datadog API and allows you to send data (e.g., metrics and logs) to the Datadog API.

An Application key is associated with both a specific user and with authorization scopes. Together, these two things determine what actions the Application key is authorized to perform on the Datadog API.

Provisioning a Datadog API key

  1. Click your profile picture on the lower left-hand side of the Datadog UI. Choose the Organization settings button in the popover menu.

  2. On the left-hand side of the Organization settings page, click the API Keys tab.

  3. In the upper right-hand side of the API Keys page, click the New Key button.

  4. Provide a name for the Datadog API key, and click Create Key.

  5. Click the Copy button to copy the API key to your clipboard. Store this API key in a secure location, as you will need it for the next step. When you are done, click the Finish button.

Provisioning a Datadog Application key

  1. From the Settings page, click the Application Keys tab.

  2. Click the New Key button.

  3. Provide a name for the Datadog Application key, and click Create Key.

  4. Click the Copy button to copy the Application key to your clipboard. Store this Application key in a secure location, as you will need it for the next step.

    Note: "Not scoped" means "all scopes of the user provisioning the key." For example, if the user provisioning has the Datadog Admin role, the Application key will have the same permissions.

    When you are done, click the Finish button.

Add Datadog Integration to Atlas

Once the Datadog API key is provisioned, we will need to make it available to your running Atlas instance. We will do this by:

  1. Adding the Datadog API key to the Atlas configuration as an environment variable, e.g., DDOG_API_KEY.

  2. Adding the Datadog Application key to the Atlas configuration as an environment variable, e.g., DDOG_APPLICATION_KEY.

  3. Configuring the Atlas deployment to use an HTTP adapter that adds the Datadog API key to the DD-API-KEY header.

  4. Configuring the Atlas deployment to use an HTTP adapter that adds the Datadog Application key to the DD-APPLICATION-KEY header.

Step 1: Add Datadog API key to Atlas Deployment as an Environment Variable

  • Choose an environment variable name for the Datadog API key. Generally this is something like DDOG_API_KEY.

  • Choose an environment variable name for the Datadog Application key. Generally this is something like DDOG_APPLICATION_KEY.

  • Add the Datadog API token you provisioned as an environment variable to your Atlas deployment. The install guides have instructions for how to do this for each deployment method. For example, if you deployed Atlas using ECS, you might add an environment variable DDOG_API_KEY to the Pulumi configuration. If you deployed using Kubernetes, you might add the DDOG_API_KEY environment variable to a .env file.

  • Note the name of the environment variable you chose. We will use this in the next step to configure the HTTP adapter.

Step 2: Add Datadog API key and Application key to Atlas Configuration

We can use the mom CLI to add the Datadog API and Applicaiton key to the Atlas configuration. Run this command, changing

  • YOUR_ATLAS_CONFIG.yml with the path to your Atlas configuration file

  • DDOG_API_KEY to the name of the environment variable you chose in the previous step

  • DDOG_APPLICATION_KEY to the name of the environment variable you chose in the previous step

  • YOUR_ADAPTER_NAME to the name you want to use for the HTTP adapter in Atlas, e.g., datadog

mom atlas config add-http-adapter \
    -f YOUR_ATLAS_CONFIG.yml \
    --adapter-name YOUR_ADAPTER_NAME \
    --base-url https://api.datadoghq.com/api \
    -H 'DD-API-KEY: ${{ DDOG_API_KEY }}' \
    -H 'DD-APPLICATION-KEY: ${{ DDOG_APPLICATION_KEY }}'

The diff in your version control system should look something like this:

diff --git a/YOUR_ATLAS_CONFIG.yml b/YOUR_ATLAS_CONFIG.yml
index fd4ad16..3d98f5b 100644
--- a/YOUR_ATLAS_CONFIG.yml
+++ b/YOUR_ATLAS_CONFIG.yml
@@ -8,6 +8,10 @@ spec:
       apiVersion: moment.dev/adapters/v1alpha1
       kind: HTTP
       name: brex
+  - adapterRef:
+      apiVersion: moment.dev/adapters/v1alpha1
+      kind: HTTP
+      name: YOUR_ADAPTER_NAME
   exposedPorts: {}
   gatewayRegistration:
     backoff:
@@ -34,3 +38,15 @@ spec:
   headers:
   - name: Authorization
     value: Bearer ${{ BREX_API_TOKEN }}
+---
+apiVersion: moment.dev/adapters/v1alpha1
+kind: HTTP
+metadata:
+  name: YOUR_ADAPTER_NAME
+spec:
+  baseUrl: https://api.datadoghq.com/api
+  headers:
+  - name: DD-API-KEY
+    value: ${{ DDOG_API_KEY }}
+  - name: DD-APPLICATION-KEY
+    value: ${{ DDOG_APPLICATION_KEY }}

Step 3: Deploy the Updated Atlas Config

The install guides have instructions for how to deploy Atlas into a variety of environments, including Kubernetes and ECS.

Step 4: Test the Integration

Once deployed, we can use the mom curl command to test the integration. Be sure to replace datadog with the name you chose in the previous step if it is something else.

mom curl /v1/apis/http/datadog/v2/users

Using the integration in a canvas

This integration can be used in Moment by creating a new cell in a Moment canvas, and pasting the following code. Note that you will need to assign httpAdapterName to the name you chose for the HTTP adapter in the previous step, e.g., datadog or ddog.

const httpAdapterName = "datadog"; // or "ddog"
const response = await atlasProxyFetch(`/v1/apis/http/${httpAdapterName}/api/v2/users`);
return await response.json();

If the integration is working, you should see a JSON object with a list of Datadog users.

Last updated