LiteLLM with Datadog logs, metrics and LLM Observability

LiteLLM ships five Datadog integration paths that send different data. This page explains which to enable, what each sends, and how to set them up without leaking prompt content.

On this page

How LiteLLM connects to Datadog and which integration to choose

A platform team running a self-hosted LiteLLM gateway usually has to make its traffic visible in Datadog, but LiteLLM does not offer one Datadog connection. It offers five routes, and each sends a different slice of data: datadog for Datadog Logs, datadog_llm_observability for LLM traces, datadog_metrics for custom metrics, datadog_cost_management for spend views, and ddtrace-run for APM traces. The datadog callback logs both successful and failed LLM calls, so failed requests are visible in log search from the start. Choose the integration by the question your team needs Datadog to answer: searching request records, inspecting prompts and tool calls as LLM traces, charting latency and error rates over time, reviewing spend by model or team, or following a request through the application's services in APM.

Most teams do not need every route on day one. Start by listing the consumers of the data. Security and audit staff usually want searchable records of each call, which points to the logs callback. Platform engineers who run dashboards and alerts want time series, which points to the metrics route. FinOps staff who reconcile against provider invoices want the cost route, and developers debugging a prompt chain want the LLM Observability view. Enabling several callbacks sends the same request to several destinations, so confirm with the Datadog account owner which products are licensed and which index or retention settings apply before turning them on. Check the exact setting names and environment variables in the LiteLLM Datadog documentation for your release, because callback names and required keys can change between versions.

Before you enable any route, confirm three things in your own environment: which Datadog site and API key the gateway will use, where that key is stored (it belongs in a secret manager, not in plain configuration), and whether prompt and response bodies may leave your network. Those answers decide whether metadata-only logging is enough or whether body capture needs a masking step first. Plan a test with a non-production key, send one successful and one deliberately failed request, and confirm both appear in the chosen Datadog product before rolling the configuration out to production gateways.

What you need before enabling the Datadog callbacks

Enabling the Datadog callbacks is simple to configure but depends on several pieces already being in place. The cards below cover the gateway version, the Datadog account, network paths, the shared data stores and how credentials are held, so the integration can be tested in a controlled way before it carries production traffic.

A supported LiteLLM release

Start from a running proxy on one of the four most recent stable minor versions, since LiteLLM maintains support for that window for open source and Enterprise deployments. Check the current release list before you pin a version, because the newest tag published on the releases page may not match what your environment has tested. Confirm that the Datadog callback names and settings in your target version match the LiteLLM Datadog docs, because callback behavior can change between minor releases.

Supported minor versions
4
LiteLLM releases

Datadog account, site and API key

Confirm which Datadog site your organization uses, since the endpoint the gateway sends to depends on it, and create an API key in that account for the gateway rather than reusing a personal key. Confirm with your Datadog administrator which key scopes the chosen integration needs, and whether LLM Observability or Cloud Cost Management require additional product access on your plan. Record the owner of the key so rotation has a clear point of contact.

LiteLLM Datadog docs

Egress from the gateway to Datadog

The gateway host or pods must reach the Datadog intake endpoints for your site over HTTPS. In restricted networks, add the required destinations to the egress allowlist and test them from the same subnet and proxy path the gateway uses, not from a workstation. Confirm with your network team whether traffic goes through an outbound proxy, since a proxy that inspects TLS can break the connection without a clear error in the gateway logs.

PostgreSQL and Redis for multiple instances

PostgreSQL is the primary supported database, and virtual keys need it, so confirm that the database is in place before relying on per-key spend data alongside Datadog events. Once more than one proxy instance runs, Redis 7.0 or newer is required for shared rate limits, router state and cache. Plan these data stores in the same change window as the callback rollout, so a failure in one does not look like a Datadog problem.

Keys stored in a secret manager

Keep the Datadog API key and LITELLM_MASTER_KEY, which must start with sk-, in a secret manager rather than in plain config files or environment variables committed to source control. Decide how the key reaches the pod or host at startup, how it is rotated, and who can read it. Check whether your secret manager is supported for your edition, since Enterprise adds integrations with AWS, Azure, Google, HashiCorp Vault and CyberArk.

LiteLLM production guide

A test plan before production traffic

Decide which Datadog integration you are testing, then send a small set of test calls through a non-production key to confirm that successful and failed requests appear where you expect. Record the metadata fields you rely on, check whether prompt content leaves the gateway, and confirm that the team receiving the data has agreed to that. Only move the callback to production after the test results match the data handling decisions your security and privacy reviewers approved.

How to configure each Datadog integration in order

This sequence adds each Datadog integration to one LiteLLM gateway in a fixed order, so every new callback is checked against a working log flow before the next one is enabled. The end state is one test request visible in Logs, LLM Observability, Metrics, Cloud Cost Management and APM.

  1. Store the Datadog and master keys in your secret manager

    The platform team stores the Datadog API key and the LITELLM_MASTER_KEY in the secret manager the gateway already uses, and keeps both out of the configuration repository. LiteLLM requires the master key to start with sk-. Inject both values as environment variables at runtime, and confirm the Datadog site setting matches your Datadog account. Done when the proxy starts cleanly, its health check passes, and neither key appears in the config files or container logs.

  2. Enable the datadog callback and confirm logs

    Add datadog to the callback list in the proxy configuration, then restart the proxy. The LiteLLM Datadog docs describe this callback as logging both successful and failed LLM calls, so confirm the exact callback key names for your release in the LiteLLM Datadog docs. Send one successful test request with a virtual key, then send one deliberately failing request, such as an unknown model name. Done when both requests appear in Datadog Logs under the service name you configured, with matching key and model metadata.

  3. Add the LLM Observability callback

    Add datadog_llm_observability next to datadog and leave the Logs callback running so you can compare the two views. Before enabling it, decide whether prompt and response content should reach Datadog, because that is a data flow decision for your security and privacy teams. Send a chat call with metadata fields such as team and key alias so traces are easy to filter. Done when the trace appears in the LLM Observability view with the same request ID you saw in Logs, showing the model, token counts and latency.

  4. Add the custom metrics callback

    Add datadog_metrics to the callback list and restart the proxy. Send a small batch of test calls across at least two models so the metric has more than one series to group by. Open Metrics Explorer, search for the LiteLLM metric names your release emits, and confirm the test calls appear as data points. Confirm the metric names in the LiteLLM Datadog docs, because names can change between releases. Ask Datadog how custom metrics are billed on your plan, since each unique tag combination counts as a separate series. Done when the counts grouped by model match the number of test calls you sent.

  5. Enable the Cloud Cost Management callback

    Add datadog_cost_management only after the earlier callbacks are verified, so a cost problem cannot hide a log problem. Send a few calls to a priced model and record the token counts for each one. Check Cloud Cost Management for LLM spend tagged to the expected service, and confirm with Datadog whether this callback needs a separate cost data source configured on your account. Reconcile a sample of the test calls against the provider's own usage report for the same window. Done when the Datadog figure for the test calls lines up with the provider's usage data, and any gap is explained before anyone uses the figure for chargeback.

  6. Run the proxy under ddtrace-run for APM

    Start the proxy under ddtrace-run only after the callback steps pass, so tracing is the last change and is easy to roll back. Set the service name and environment so proxy traces are grouped apart from application traces. Confirm the start command and the ddtrace version against Datadog's current documentation, because the wrapper changes how the process launches. Send a test request and open APM Trace Explorer, filtering on the service name. Done when a trace shows the HTTP request through the proxy to the provider call, and reverting the start command returns the proxy to its earlier behavior.

What each Datadog integration sends and who uses it

The datadog callback sends request logs for successful and failed LLM calls to Datadog Logs. Security and log teams that already search and alert in Datadog can use these logs to review AI usage alongside other application logs, without adding a separate log store.

  • Call outcomes: Successful and failed calls are both logged, so provider errors, timeouts and error bursts can be searched and alerted on.
  • Caller attribution: Logs carry the identifiers LiteLLM attaches to each call, such as key, team or model details. Confirm the exact field names in your LiteLLM version before you write searches against them.
  • Typical uses: Hunting for unusual usage by key, building audit-style searches and setting alerts on failure rates.
  • Prompt and response content: Confirm whether message bodies appear in the log payload under your configuration and version. Treat this as a data-protection decision until it is verified in a test environment.
  • Retention and access: Index retention and who can read the logs are controlled in Datadog, so agree both with the security team before go-live.

Send a test prompt containing dummy personal data through a non-production key, then inspect the resulting log entry before you widen access to the index.

How LiteLLM fields map to Datadog logs, traces and metrics

This table lists the LiteLLM request fields teams usually filter on and where each one lands in Datadog Logs, LLM Observability spans, metrics and cost views. Read each row as a question to answer before you build dashboards or monitors. Confirm every exact attribute name in the LiteLLM Datadog docs for your release, because the names are not final until you check them.

LiteLLM fieldWhere it appears in DatadogWhat to filter on or confirm
Model and providerLog attributes, LLM Observability span fields and a metric tag. Exact names to confirm in the LiteLLM Datadog docs.Filter by model to compare provider cost and error rates. Confirm whether provider and model are separate attributes.
Key alias and team aliasLog attributes and metric tags for per-team views. Exact names to confirm in the LiteLLM Datadog docs.Confirm whether aliases or hashed key IDs are sent. Raw virtual key values should never reach Datadog.
Call status (success or failure)Log entries for both successful and failed calls. Status field name to confirm.Build error-rate monitors from this field. Confirm how the error type and message are attached to failed calls.
LatencyLog duration attribute and LLM Observability span timing. Confirm the exact field name.Confirm whether the value is total request time or time to first token before using it in latency SLOs.
Spend and costCost Management views through the datadog_cost_management integration and spend values on logs or metrics.Confirm the currency and unit and compare totals against each provider's invoice before chargeback.
Token countsInput and output token fields on LLM Observability spans and related log attributes. Names to confirm.Use tokens with spend to check whether cost tracking matches provider usage reports.
Prompt and response contentInput and output fields on logs and LLM Observability spans, if the integration is set to send them.Confirm whether bodies are sent by default. Decide masking and retention before enabling content capture.
Request and trace identifiersCorrelation fields that link a LiteLLM call to APM traces when ddtrace-run is used. Confirm names.Confirm the trace and span ID fields so one request can be followed from the gateway into your application.

Keeping prompts, keys and tags safe in Datadog

Once LiteLLM sends logs to Datadog, the main risks are what leaves the gateway, who can read it, and which identifiers end up as searchable tags. The cards below cover the decisions to make before turning on any Datadog callback, in the order they usually come up.

Store the Datadog API key in a secret manager

The Datadog callback authenticates with a Datadog API key that the LiteLLM proxy reads from its environment. Keep that key in the secret manager your platform already uses, inject it at runtime, and keep the LiteLLM master key (which must start with sk-) in the same controlled store. Confirm which Datadog key type the callback requires, scope it to the minimum needed, and plan a rotation runbook that lists every gateway instance using it.

Decide whether bodies reach Datadog

Before enabling any integration, decide whether prompts and responses may leave your environment. Metadata alone (model, team, key alias, latency, cost, status) answers most operational questions. Request and response bodies answer debugging and abuse questions but expand what Datadog stores and who can read it. Record the decision per integration, because the Datadog Logs callback and the LLM Observability integration may differ in what they capture.

Datadog docs

Mask content before callbacks run

If bodies must be logged, mask sensitive values before they reach any logging callback rather than relying on Datadog-side filtering after ingestion. Identify the data classes that appear in your prompts, such as account numbers, national identifiers, health details and credentials, and test your masking rules against representative traffic. Confirm with your LiteLLM version which hooks run before each callback, and test that a masked value never appears in a Datadog log event.

Restrict Datadog access to AI traffic logs

Logs from the gateway often contain user identifiers and prompt text, so they should not sit in a general-purpose log index that all engineers can search. Use Datadog role-based access and log restriction queries to limit who can view AI traffic, and separate indexes by sensitivity where your plan allows. Review who holds the roles that can read full log content, and record the review in the same place as your key rotation runbook.

Keep high-cardinality and personal data out of tags

Datadog tags drive metric series and facet search, so values such as individual user emails, request IDs or full prompt hashes create high-cardinality series and can expose personal data in dashboards. Limit metric tags to bounded values such as team, model group and environment, and keep per-user or per-request identifiers in log attributes that you can restrict. Check each tag against the cardinality and privacy questions before adding it to a metric.

Align gateway key and budget settings with what is sent

LiteLLM virtual keys, teams and budgets determine which identifiers appear in spend and request metadata. Use key aliases and team names that are meaningful to Datadog users but contain no personal data, since these values are often the ones that get tagged. Confirm which key and team fields each integration forwards, and test a sample request end to end to see exactly what Datadog receives.

How requests flow from applications through LiteLLM into Datadog

The path starts with applications sending OpenAI-format calls to the self-hosted LiteLLM proxy, which routes each call to an approved model provider. Callbacks configured on the proxy then send request logs, LLM traces, metrics and cost data from the team's infrastructure to Datadog's SaaS endpoints. The trust boundary sits between those two sides, and the secret store supplies the Datadog API key to the proxy, so check what each callback sends across that line before you enable it.

Request path from applications through the LiteLLM proxy to Datadog endpoints, with the trust boundary marked.

How to test the integration and what breaks most often

How do I test that LiteLLM is sending a successful request to Datadog?

Make one known-good test call through the proxy, then search for it in Datadog using the model name or a unique metadata tag you attached to the request. Test each Datadog product separately, since a working log stream does not prove that LLM Observability or metrics are receiving data. Keep the test prompt harmless and use a dedicated test key so the record is easy to find and filter. Check that the record shows the model, the latency and the token counts, not only that the request appeared. If the call does not appear, check the proxy logs for callback errors before changing the Datadog configuration.

How do I test a failed request so I know error logging works?

Send a deliberately invalid request, such as a call to a model name that is not configured or a request with a bad provider key on a test route. A correct setup records the failure as an error event in Datadog, so confirm that the failed call appears alongside the successful ones. Failed-call records are what your security and operations teams need during an incident, so treat this test as required rather than optional. Do not test failures against production provider keys that could be locked out by repeated errors.

Why does my Datadog site setting matter, and how do I check it?

A wrong or missing Datadog site sends data to a region where your account does not exist, so the integration appears to run but nothing shows up. Confirm the site that your Datadog organization uses and set it in the same form the LiteLLM Datadog documentation describes. Then compare the Datadog account settings with the environment variables that the proxy process actually reads, because a value set only in a shell or a local file often does not reach the container.

What causes an invalid API key error with the Datadog integration?

An invalid key usually means the Datadog API key in the proxy environment is wrong, expired, belongs to another organization, or was copied with extra whitespace. Store the key in your secret manager and confirm the running pod or process received the current value. Use a key scoped for ingestion rather than a personal key, and rotate it through your normal process. Expect the failure to show up as missing data rather than a clear proxy error, so check the callback logs first.

Why do Datadog logs stop appearing after I scale the gateway?

The most common cause is that the Datadog callback is enabled on some proxy instances but not others. Each replica reads its own configuration, so requests served by an unconfigured instance produce no Datadog records. Compare the effective configuration on every instance, including any new replicas created by autoscaling, and confirm the same settings are deployed from one source of truth. Sample traffic across replicas after a change to confirm that records arrive from each one.

What should I check when egress is blocked from the gateway to Datadog?

Blocked egress causes the proxy to lose telemetry while model traffic still works, which makes the problem easy to miss. Confirm that the gateway's network path allows outbound HTTPS to the Datadog endpoint for your site, including through any proxy, firewall or egress policy in a restricted network. Check the proxy logs for connection timeouts or refused connections. Ask your network team to confirm the rule in the environment where the gateway runs, not in a test network.

Why are there no traces when I use the ddtrace-run wrapper?

Tracing only works when the proxy process starts under the ddtrace-run wrapper, so a container entrypoint or Kubernetes command that bypasses the wrapper produces no traces even when logs arrive. Check the process command in the running container and confirm that tracing environment variables are set where that process runs. Verify tracing separately from logs and LLM Observability, because each Datadog product has its own path and its own failure mode.

How DeployOpen scopes and delivers the Datadog integration

DeployOpen plans, implements, documents and supports self-hosted LiteLLM gateways inside your own infrastructure, including the Datadog callbacks for logs, LLM Observability, metrics and cost data. Each engagement starts from a written scope that names which Datadog integrations you need and what each one will send.

How we scope

  • Inventory which Datadog products your teams already run and which ones the gateway data must reach.
  • Decide which of the Datadog logs, LLM Observability, metrics, cost management and ddtrace options apply, and record what each sends.
  • Agree in writing what data leaves the gateway, which fields are excluded, and who approves the Datadog site and API key handling.

How we build

  • Configure the LiteLLM callbacks and Datadog settings in your gateway configuration, managed as code where your team already works that way.
  • Store the Datadog API key in your secret manager rather than in plain configuration files, and confirm the key is scoped to the required permissions.
  • Test successful and failed model calls end to end in a non-production environment, checking that logs, traces and metrics arrive as the scope describes.

How we hand over

  • Document the enabled integrations, the data each one sends, the configuration keys used and the rollback steps.
  • Walk your platform, security and observability teams through the Datadog dashboards, monitors and log queries built during the engagement.
  • Deliver a verification record showing test calls, the Datadog entries they produced, and open items for your team to confirm.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, so the Datadog configuration keeps pace with LiteLLM releases.
  • Re-test the integration after gateway upgrades, Datadog agent or site changes, and any change to the fields your teams send to Datadog.
  • Ask for the support scope, response expectations and upgrade handling in writing before the retainer starts, since these are set per agreement.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.