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.
Public beta. This integration is available to all Atlas users, but the API may change.
- A running instance of Atlas. See installation guides for more details.
- Datadog Admin Role permissions in Datadog.
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.
-
Click your profile picture on the lower left-hand side of the Datadog UI. Choose the Organization settings button in the popover menu.
-
On the left-hand side of the Organization settings page, click the API Keys tab.
-
In the upper right-hand side of the API Keys page, click the New Key button.
-
Provide a name for the Datadog API key, and click Create Key.
-
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.
-
From the Settings page, click the Application Keys tab.
-
Click the New Key button.
-
Provide a name for the Datadog Application key, and click Create Key.
-
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.
Once the Datadog API key is provisioned, we will need to make it available to your running Atlas instance. We will do this by:
- Adding the Datadog API key to the Atlas configuration as an environment variable, e.g.,
DDOG_API_KEY
. - Adding the Datadog Application key to the Atlas configuration as an environment variable, e.g.,
DDOG_APPLICATION_KEY
. - Configuring the Atlas deployment to use an HTTP adapter that adds the Datadog API key to the
DD-API-KEY
header. - Configuring the Atlas deployment to use an HTTP adapter that adds the Datadog Application key to the
DD-APPLICATION-KEY
header.
- 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 theDDOG_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.
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 fileDDOG_API_KEY
to the name of the environment variable you chose in the previous stepDDOG_APPLICATION_KEY
to the name of the environment variable you chose in the previous stepYOUR_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 }}
The install guides have instructions for how to deploy Atlas into a variety of environments, including Kubernetes and ECS.
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
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.