---
title: Serverless Agent configuration
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Serverless > Serverless Monitoring Guides > Serverless Agent
  configuration
---

# Serverless Agent configuration

## Overview{% #overview %}

The Agent's [main configuration file](https://github.com/DataDog/datadog-agent/blob/main/pkg/config/config_template.yaml) is `datadog.yaml`. For the serverless Agent, `datadog.yaml` configuration options are passed in with environment variables. The environment variables are usually named as their config options in capital snake case. For example, set your Datadog API key as `DD_API_KEY`.

### Basic configuration{% #basic-configuration %}

| Environment Variable                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DD_API_KEY`                        | The environment variable with your Datadog API key, in plaintext. **One** key environment variable is required. See [serverless CLI environment variables](https://docs.datadoghq.com/serverless/libraries_integrations/cli/#environment-variables).                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `DD_KMS_API_KEY`                    | The environment variable with your Datadog API key, using KMS. **One** key environment variable is required. See [serverless CLI environment variables](https://docs.datadoghq.com/serverless/libraries_integrations/cli/#environment-variables).                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `DD_API_KEY_SECRET_ARN`             | The environment variable with your Datadog API key, using an AWS Secrets Manager secret. **One** key environment variable is required. See [serverless CLI environment variables](https://docs.datadoghq.com/serverless/libraries_integrations/cli/#environment-variables).                                                                                                                                                                                                                                                                                                                                                                                                      |
| `DD_API_KEY_SECRET_RELOAD_INTERVAL` | Only applicable when `DD_API_KEY_SECRET_ARN` is set. The interval (in seconds) at which to periodically reload the API key from AWS Secrets Manager. The reload is triggered lazily when the API key is needed for a flush and the interval has elapsed. If unset or `0`, the secret is loaded once and never reloaded. Available for version 88+ of the Datadog Lambda Extension. **Best practice for key rotation:** when rotating your API key, keep the old key valid for a grace period after creating the new one, and set this interval to a value shorter than that grace period. This helps ensure the extension always reloads the new key before the old one expires. |
| `DD_LOG_LEVEL`                      | Set the level for the [Datadog Agent log](https://docs.datadoghq.com/agent/troubleshooting/debug_mode/?tab=agentv6v7#agent-log-level).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `DD_SERVERLESS_FLUSH_STRATEGY`      | Datadog Agent flushing strategy. Values permitted are `end` or `periodically[,milliseconds]`. For example, `DD_SERVERLESS_FLUSH_STRATEGY=periodically,100` flushes every 100ms.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `DD_ENV`                            | Sets the global tag `env` tag for all data emitted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `DD_TAGS`                           | Host tags separated by spaces. For example: `simple-tag-0 tag-key-1:tag-value-1`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `DD_SITE`                           | Destination site for your metrics, traces, and logs. Set your Datadog site to: ``. Defaults to `datadoghq.com`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `DD_DD_URL`                         | Optional setting to override the URL for metric submission.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `DD_URL`                            | Alias for `DD_DD_URL`. Ignored if `DD_DD_URL` is already set.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `DD_TRACE_ENABLED`                  | Enables trace collection. Defaults to `true`. For more information about trace collection environment variables, see [Library Configuration](https://docs.datadoghq.com/tracing/trace_collection/library_config/).                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `DD_TAGS`                           | List of tags. Attached in-app to every metric, event, log, trace, and service check emitted by this Agent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `DD_TAG_VALUE_SPLIT_SEPARATOR`      | Split tag values according to a given separator. Only applies to host tags, and tags coming from container integrations. It does not apply to tags on DogStatsD metrics, or tags collected by other integrations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|  |

### Log collection configuration{% #log-collection-configuration %}

| Environment Variable                          | Description                                                                                                                                                                                                                                                                                                                                                         |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DD_LOGS_ENABLED`                             | Set to `true` to enable Datadog Agent log collection.                                                                                                                                                                                                                                                                                                               |
| `DD_LOGS_CONFIG_LOGS_DD_URL`                  | Define the endpoint and port to hit when using a proxy for logs. Because logs are forwarded in TCP, the proxy must be able to handle TCP connections. String in the format `<ENDPOINT>:<PORT>`.                                                                                                                                                                     |
| `DD_LOGS_CONFIG_LOGS_NO_SSL`                  | Disable the SSL encryption. This parameter should only be used when logs are forwarded locally to a proxy. It is highly recommended to then handle the SSL encryption on the proxy side.                                                                                                                                                                            |
| `DD_LOGS_CONFIG_PROCESSING_RULES`             | Global processing rules that are applied to all logs. The available rules are `exclude_at_match`, `include_at_match`, and `mask_sequences`. For more information, see [Global Processing Rules](https://docs.datadoghq.com/agent/logs/advanced_log_collection/#global-processing-rules).                                                                            |
| `DD_LOGS_CONFIG_FORCE_USE_HTTP`               | By default, the Agent sends logs in HTTPS batches to port 443 if HTTPS connectivity can be established at Agent startup, and falls back to TCP otherwise. Set this parameter to `true` to always send logs with HTTPS (recommended).                                                                                                                                |
| `DD_LOGS_FORCE_USE_TCP`(Deprecated)           | By default, logs are sent through HTTPS if possible. Set this parameter to `true` to always send logs via TCP. If `DD_LOGS_CONFIG_FORCE_USE_HTTP` is set to `true`, this parameter is ignored.**Note**:TCP log collection is **not supported**. Datadog provides **no delivery or reliability guarantees** when using TCP, and log data may be lost without notice. |
| `DD_LOGS_CONFIG_USE_COMPRESSION`              | This parameter is available when sending logs with HTTPS. If set to `true`, the Agent compresses logs before sending them.                                                                                                                                                                                                                                          |
| `DD_LOGS_CONFIG_COMPRESSION_LEVEL`            | This parameter accepts values from `0` (no compression) to `9` (maximum compression but higher resource usage). Only takes effect if `DD_LOGS_CONFIG_USE_COMPRESSION` is set to `true`.                                                                                                                                                                             |
| `DD_LOGS_CONFIG_BATCH_WAIT`                   | The maximum time (in seconds) the Datadog Agent waits to fill each batch of logs before sending. Default to `5`.                                                                                                                                                                                                                                                    |
| `DD_LOGS_CONFIG_OPEN_FILES_LIMIT`             | The maximum number of files that can be tailed in parallel. Default is `500`.                                                                                                                                                                                                                                                                                       |
| `DD_LOGS_CONFIG_FILE_WILDCARD_SELECTION_MODE` | The strategy used to prioritize wildcard matches if they exceed the open file limit. Available values are `by_name` and `by_modification_time`.                                                                                                                                                                                                                     |
| `DD_LOGS_CONFIG_LAMBDA_LOGS_TYPE`             | Source of logs to export. Value permitted is a space separated list of `function`, `platform`, `extension`. Default is everything.                                                                                                                                                                                                                                  |

### APM configuration{% #apm-configuration %}

| Environment Variable      | Description                                                                                                                                                                                                                      |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DD_APM_ENABLED`          | Set to `true` to enable the APM Agent. Defaults to `true`.                                                                                                                                                                       |
| `DD_APM_ENV`              | The environment tag that traces are tagged with. If this variable is not set, the value is inherited from `DD_ENV`. If `DD_ENV` is not set, then this value is inherited from the `env:` tag set in `DD_TAGS`.                   |
| `DD_APM_RECEIVER_PORT`    | The port that the trace receiver listens on. Set to `0` to disable the HTTP receiver. Default: `8126`.                                                                                                                           |
| `DD_APM_RECEIVER_SOCKET`  | Accept traces through Unix Domain Sockets. It is off by default. When set, it must point to a valid socket file.                                                                                                                 |
| `DD_APM_DD_URL`           | Define the endpoint and port to hit when using a proxy for APM. String in the format `<ENDPOINT>:<PORT>`. Because traces are forwarded in TCP, the proxy must be able to handle TCP connections.                                 |
| `DD_APM_REPLACE_TAGS`     | Defines a set of rules to replace or remove certain tags that contain [potentially sensitive information](https://docs.datadoghq.com/tracing/setup_overview/configure_data_security/#replace-rules-for-tag-filtering).           |
| `DD_APM_IGNORE_RESOURCES` | An exclusion list of regular expressions. Any trace with a resource name that matches one of these expressions is ignored. Use a comma-separated list and surround each entry with double quotes. For example: `"^foo$", "bar$"` |

### Advanced networking configuration{% #advanced-networking-configuration %}

| Environment Variable     | Description                                                                                                                                                                                                                                       |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DD_SKIP_SSL_VALIDATION` | Set this option to `true` to tell the Agent to skip validation of SSL/TLS certificates. Defaults to `false`.                                                                                                                                      |
| `DD_MIN_TLS_VERSION`     | This option defines the minimum TLS version for submitting data to the Datadog intake specified in `DD_SITE` or `DD_URL`. Possible values are: `tlsv1.0`, `tlsv1.1`, `tlsv1.2`, or `tlsv1.3`. Values are case-insensitive. Defaults to `tlsv1.2`. |

### Proxy settings{% #proxy-settings %}

| Env Variable        | Description                                                       |
| ------------------- | ----------------------------------------------------------------- |
| `DD_PROXY_HTTP`     | An HTTP URL to use as a proxy for `http` requests.                |
| `DD_PROXY_HTTPS`    | An HTTPS URL to use as a proxy for `https` requests.              |
| `DD_PROXY_NO_PROXY` | A space-separated list of URLs for which no proxy should be used. |

For more information about proxy settings, see the [Agent v6 Proxy documentation](https://docs.datadoghq.com/agent/configuration/proxy/#agent-v6).

### DogStatsD (custom metrics){% #dogstatsd-custom-metrics %}

Send custom metrics with [the StatsD protocol](https://docs.datadoghq.com/extend/dogstatsd/):

| Env Variable                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DD_DOGSTATSD_NON_LOCAL_TRAFFIC`                  | Listen to DogStatsD packets from other containers (required to send custom metrics).                                                                                                                                                                                                                                                                                                                                                                             |
| `DD_DOGSTATSD_SOCKET`                             | Path to the Unix socket to listen to. Must be in a `rw` mounted volume.                                                                                                                                                                                                                                                                                                                                                                                          |
| `DD_DOGSTATSD_ORIGIN_DETECTION`                   | Enable container detection and tagging for Unix socket metrics.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `DD_DOGSTATSD_TAGS`                               | Space-separated list of additional tags to append to all metrics, events, and service checks received by this DogStatsD server. For example: `"env:golden group:retrievers"`.                                                                                                                                                                                                                                                                                    |
| `DD_USE_DOGSTATSD`                                | Enable or disable sending custom metrics from the DogStatsD library.                                                                                                                                                                                                                                                                                                                                                                                             |
| `DD_DOGSTATSD_PORT`                               | Override the Agent DogStatsD port.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `DD_BIND_HOST`                                    | The host to listen on for DogStatsD and traces. This is ignored by APM when `apm_config.apm_non_local_traffic` is enabled and ignored by DogStatsD when `dogstatsd_non_local_traffic` is enabled. The Trace Agent uses this host to send metrics to.**Note**: The `localhost` default value is invalid in IPv6 environments where DogStatsD listens on `::1`. To solve this problem, ensure DogStatsD is listening on IPv4 by setting this value to `127.0.0.1`. |
| `DD_DOGSTATSD_ORIGIN_DETECTION_CLIENT`            | When set to `true`, the Agent uses a client-provided container ID to enrich the metrics, events, and service checks with container tags.**Note**: This requires using a client compatible with DogStatsD protocol version 1.2.                                                                                                                                                                                                                                   |
| `DD_DOGSTATSD_BUFFER_SIZE`                        | The buffer size used to receive StatsD packets, in bytes.                                                                                                                                                                                                                                                                                                                                                                                                        |
| `DD_DOGSTATSD_STATS_ENABLE`                       | Publish DogStatsD's internal stats as Go expvars.                                                                                                                                                                                                                                                                                                                                                                                                                |
| `DD_DOGSTATSD_QUEUE_SIZE`                         | Configure the internal queue size of the DogStatsD server. Reducing the size of this queue reduces the maximum memory usage of the DogStatsD server, but can also increase the number of packet drops.                                                                                                                                                                                                                                                           |
| `DD_DOGSTATSD_STATS_BUFFER`                       | Set how many items should be in the DogStatsD's stats circular buffer.                                                                                                                                                                                                                                                                                                                                                                                           |
| `DD_DOGSTATSD_STATS_PORT`                         | The port for the Go expvar server.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `DD_DOGSTATSD_SO_RCVBUF`                          | **POSIX systems only**: Sets the number of bytes allocated to DogStatsD's socket receive buffer. By default, the OS sets this value. Use this variable to increase the size of the buffer without altering the OS default value. The maximum accepted value depends on the OS.                                                                                                                                                                                   |
| `DD_DOGSTATSD_METRICS_STATS_ENABLE`               | When set to `true`, DogStatsD collects basic statistics (count/last seen) about the metrics it processed. Use the Agent command `dogstatsd-stats` to see these statistics.                                                                                                                                                                                                                                                                                       |
| `DD_DOGSTATSD_NO_AGGREGATION_PIPELINE`            | Enable the no-aggregation pipeline in DogStatsD. This pipeline receives metrics with timestamps and forwards them to the intake without extra processing, except for tagging.                                                                                                                                                                                                                                                                                    |
| `DD_DOGSTATSD_NO_AGGREGATION_PIPELINE_BATCH_SIZE` | How many metrics maximum in payloads sent by the no-aggregation pipeline to the intake.                                                                                                                                                                                                                                                                                                                                                                          |
| `DD_STATSD_FORWARD_HOST`                          | Forward every packet received by the DogStatsD server to another StatsD server. Make sure that forwarded packets are regular StatsD packets and **not** DogStatsD packets, as your other StatsD server might not be able to handle them.                                                                                                                                                                                                                         |
| `DD_STATSD_FORWARD_PORT`                          | Port to forward StatsD packets to.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `DD_STATSD_METRIC_NAMESPACE`                      | Set a namespace for all StatsD metrics coming from this host. Each metric received is prefixed with the namespace before it is sent to Datadog.                                                                                                                                                                                                                                                                                                                  |
