LiteLLM logs in Elasticsearch through OpenTelemetry

LiteLLM can send request logs, costs and latency to Elasticsearch through an OpenTelemetry Collector with an OTLP receiver and Elastic exporter. This page covers the setup sequence, index and retention choices for prompt data, and the failure points to plan for.

On this page

How LiteLLM logs reach Elasticsearch through OpenTelemetry

A security or platform team that needs AI gateway usage in Elasticsearch should plan on the path LiteLLM documents: an OpenTelemetry Collector with an OTLP receiver and an Elastic exporter sits between the LiteLLM proxy and the cluster. LiteLLM sends its request logs, cost data and performance data to the Collector over OTLP, and the Collector's Elastic exporter writes them into Elasticsearch. The LiteLLM Elasticsearch logging tutorial describes this arrangement, so it is the reference to validate your build against before you adapt it.

The Collector earns its place because it decouples the gateway from the storage tier. LiteLLM does not need Elasticsearch credentials, bulk-indexing behavior or index naming logic in its own configuration, and the Collector can batch, retry and transform records before they reach the cluster. The same Collector can also receive traces or metrics later and fan data out to a second backend without changing the gateway. OpenTelemetry is an observability framework and toolkit, not a storage backend, so it moves and shapes telemetry but does not store, search or visualize it. Elasticsearch supplies indexing, search and dashboards in Kibana, but it does not produce LiteLLM telemetry, and it does not decide which prompt fields are stored or masked on its own.

Before you commit to this path, confirm three things with your own environment: which LiteLLM release you run and whether its Elasticsearch callback fields match the Elastic exporter version in your Collector build, whether the Collector distribution you deploy includes the Elastic exporter, and which fields the gateway emits for each request. Verify the Collector version against the OpenTelemetry Collector releases page, since the Collector project publishes frequent minor releases. Record the data types in a short field inventory now, because index mappings and retention depend on which request, cost and latency fields actually arrive.

What you need before connecting LiteLLM to Elasticsearch

Four components have to agree before any log reaches Elasticsearch: the LiteLLM proxy and its state stores, the Elasticsearch deployment, the OpenTelemetry Collector between them, and the network and certificates that join them. Check each one against its own documentation at install time, because release lines and maintenance dates move.

LiteLLM proxy and its state stores

The proxy needs PostgreSQL as its primary supported database, and virtual keys, budgets and spend data all depend on it. Once more than one proxy instance runs, Redis 7.0 or newer is required for shared rate limits, router state and cache. Confirm the exact LiteLLM release on the GitHub releases page before you pin it, and confirm the Elasticsearch logging settings against the current LiteLLM tutorial, since the callback configuration is what you are wiring up.

LiteLLM production guide

Elasticsearch deployment choice

Decide between a self-managed cluster, ECK on your own Kubernetes, or Elastic Cloud. Self-managed and ECK use Elastic's subscription tiers, and the Platinum tier is no longer offered to new customers. Check the EOL page for your target line: 9.x reaches end of maintenance on October 15, 2027, and 8.x on January 15, 2027, so a new deployment should start on 9.x.

9.x end of maintenance
Oct 15, 2027
Elastic EOL dates

Elasticsearch license and security features

Elasticsearch's default distribution is under the Elastic License 2.0, and the AGPLv3 option is OSI-approved. Confirm which license terms your legal team accepts before choosing a distribution. Security features such as single sign-on, field- and document-level security and FIPS 140-3 mode sit in paid tiers, so confirm your subscription covers the access controls you need for prompt data indices.

Elastic licensing FAQ

Node layout for a highly available cluster

A highly available cluster needs at least three master-eligible nodes. Plan data nodes with hot, warm, cold and frozen tiers in mind, because prompt-bearing indices grow quickly and retention policy decides which tier they sit on. Ingest and coordinating roles also matter if the Collector writes at volume. Size these with your own traffic estimates rather than assumptions.

Elasticsearch node roles

OpenTelemetry Collector release to pin

The Collector sits between LiteLLM and Elasticsearch, receiving OTLP and exporting to Elastic. Pin a specific release and use the contrib distribution that includes the Elastic exporter, verifying the SHA256 checksums and SBOM files that ship with each release. Recent releases include v0.163.0, published October 16, 2026, but confirm the current release and component stability in the release notes before you deploy.

Collector releases

Network paths and certificates

Four connections need explicit rules: clients to the proxy, the proxy to PostgreSQL and Redis, LiteLLM to the Collector's OTLP receiver, and the Collector to Elasticsearch. Issue certificates for the Elasticsearch endpoint and the Collector's receiver, and decide whether the Collector authenticates incoming connections with an authenticator extension. Keep the Collector's exporter credentials in a secret store, not in plain configuration files.

Collector security practices

Configuring the Collector and LiteLLM callback, step by step

This sequence moves LiteLLM request logs, costs and latency from the gateway into Elasticsearch through an OpenTelemetry Collector, and ends with a verified document that carries the fields your analysts will query. Each step closes with a check, so a failure is found at the step where it was introduced.

  1. Confirm the target cluster and index plan

    Before any configuration, the platform team confirms which Elasticsearch cluster receives the data, which index or data stream names will be used, and who owns retention for them. Ask the Elasticsearch owner to confirm the cluster version and the license tier, since security features and some alerting depend on it. Agree on whether prompt bodies will be stored at all, because that decision changes index sizing and access rules. Done when the index names, retention owner and cluster endpoint are written down and approved by the team that operates Elasticsearch.

  2. Deploy the Collector with OTLP receiver and Elastic exporter

    The platform team deploys an OpenTelemetry Collector in the same network zone as LiteLLM, using the contrib distribution from the Collector releases page so the Elastic exporter is available. The configuration defines an OTLP receiver that accepts traffic from the gateway, an Elastic exporter that points at the cluster endpoint, and a pipeline that connects them. Keep the configuration file under version control and store the Elasticsearch credential outside the file. Done when the Collector starts without configuration errors and its health endpoint reports ready in the logs.

  3. Create a write-only Elasticsearch credential

    A cluster administrator creates a dedicated Elasticsearch user or API key for the Collector, with a role that grants write and create-index privileges only on the chosen index pattern and no read access to other indices. Store the credential in your secret manager and inject it into the Collector at runtime. Ask the Elasticsearch owner to confirm the exact privileges their version requires for the Elastic exporter, since role syntax differs between releases. Done when a test write to the chosen index succeeds with this credential and a read attempt against an unrelated index is denied.

  4. Point the LiteLLM logging callback at the Collector

    In the LiteLLM proxy configuration, the team enables the OpenTelemetry logging callback and sets the OTLP endpoint to the Collector address, following the Elasticsearch logging tutorial for the exact callback name and config keys in the release you run. Keep the master key and any provider keys in environment variables or the secret manager, not in the file. Restart or roll the proxy using your normal change process. Done when the proxy starts cleanly and its logs show the callback initialized without export errors.

  5. Send a labeled test request through the gateway

    The team sends one request through a test virtual key to a model the key is allowed to use, and gives the request a recognizable metadata tag such as a test team or request ID. Use a short, non-sensitive prompt so the test does not put real data into the index. Note the time and the request ID returned to the caller. Done when the gateway returns a successful response and the Collector logs show the span or log record was received and exported.

  6. Confirm the document arrives in the index

    In Kibana or through the Elasticsearch search API, the team searches the target index for the request ID or test tag from the previous step. They check that exactly one document appears for that request, with a timestamp near the time of the call. If nothing appears, check the Collector exporter errors first, then the credential's index privileges. Done when the document is found and its timestamp, model name and key alias match what was sent.

  7. Verify cost, latency and token fields are populated

    The team opens the test document and checks the fields analysts will rely on: model, provider, token counts, latency, and the spend or cost value. Compare the cost field with the value LiteLLM reports for the same request in its own spend view, and note any field that is empty or has a different name than expected. Ask the platform owner to confirm which field names are stable for dashboards, since the mapping may differ by LiteLLM release. Done when the cost and latency fields contain values for the test request and the team has recorded the field names in a shared mapping document.

  8. Record the configuration and confirm retention settings

    The team saves the final Collector configuration, the LiteLLM callback settings and the index template or lifecycle policy in version control, with the credential references kept out of the files. They confirm that the retention rule on the index matches the agreed policy and that only the intended roles can read it. Done when a reviewer outside the build team can read the configuration, locate the retention setting, and see that prompt bodies are either excluded or covered by the access rules agreed in the first step.

Which Elasticsearch license and tier fits a regulated logging store

Choose the Elasticsearch distribution before you size the cluster, because the license decides what you may run and which security features you can switch on. Elastic publishes source code under three licenses: the Elastic License 2.0 (the default distribution since 2021), SSPL 1.0, and AGPLv3, which Elastic added in September 2024 before the 8.16 release to offer an option approved by the Open Source Initiative. ELv2 and SSPL are not OSI-approved open source licenses. If your policy requires OSI-approved software, the AGPLv3 build is the one to evaluate, and your legal team should confirm how AGPLv3 obligations apply if you modify or offer the stack to others.

Tier matters as much as license for a regulated store. Single sign-on (SAML, OpenID Connect, Kerberos, JWT), field- and document-level security, and alerting rules based on anomaly detection sit in paid tiers, according to Elastic's subscriptions page. Those are the controls that restrict which analysts can read prompt fields and which identity provider they sign in through, so a free-tier cluster may not meet your access requirements. Elastic's subscriptions page also says the Platinum tier is no longer available to new self-managed customers, so the realistic choices for a new self-managed deployment are the Free and open (Basic) tier or Enterprise. Confirm what each tier includes today with Elastic, and ask for the terms in writing.

Before you buy or deploy, ask Elastic and your legal and procurement teams to confirm the current subscription terms, the license you will run, and whether the Elastic License 2.0 terms fit your use case. Ask which features your chosen tier includes for LiteLLM-specific needs such as field-level restriction of prompt fields, and whether the Elastic support lifecycle covers the release line you plan to run. Record the decision with the license, tier and feature list, because it determines the access model for every index that stores prompt data.

Mapping LiteLLM request fields to Elasticsearch documents

This table groups the LiteLLM request data you will query in Elasticsearch, shows whether each group is sent by default, and lists what to confirm before building dashboards. Treat the metadata rows as the baseline for analytics. Prompt and response content is a separate decision that needs its own index, access rules and retention.

Data groupWhat it containsDefault or content-dependentWhat to confirm
Request identifiersRequest ID, timestamp, call type and endpoint for each gateway callDefault metadataRequest ID matches LiteLLM's own spend log ID so records can be joined
Key and team metadataVirtual key alias, user, team and organization referencesDefault metadataRaw key values never appear in documents; check the exported field names
Model and providerRequested model name, resolved deployment and providerDefault metadataModel group names match your routing configuration for filters
Token countsPrompt, completion and total tokens per requestDefault metadataCounts are present for streaming and failed calls before you rely on them
CostComputed spend per request in the currency configured for the gatewayDefault metadataPrice data used for cost matches the provider bill, as covered in cost tracking
Latency and statusStart and end times, duration, success or failure and error typeDefault metadataTimeouts and hanging calls are logged as expected, not dropped
Prompt and response bodiesMessage content sent to and returned by modelsOnly when content storage is enabledConfirm the storage setting and the exact field names in the tutorial output
Index patterns and retentionSeparate indices for metadata and any content-bearing dataSet by your mapping and lifecycle policiesContent indices have stricter access and shorter retention than metadata indices

Choosing indices and retention for prompt data

This option keeps request metadata such as the key alias, team, model, token counts, cost and latency in indices that do not hold prompt or response bodies. Because the records carry little personal data, they are usually easier to retain for longer, share with finance and platform teams, and use for trend analysis. Most of the value for spend reviews, budget checks and latency investigations comes from this data, so it is a sensible default before anyone decides to store content.

  • Spend and latency analysis: Cost, token and duration fields answer chargeback and performance questions without exposing user text.
  • Longer retention window: Because the records are less sensitive, the retention period can be set to match finance and audit needs, subject to your policy.
  • Broader read access: Platform, FinOps and security analysts can usually query this index without a separate prompt-data approval.
  • Field discipline: Confirm which LiteLLM fields reach the collector, since metadata fields can still include user identifiers or free-text tags.
  • Storage efficiency: Smaller documents keep hot and warm tier storage costs lower than full-content indices.

Before you commit, confirm with your privacy team that no prompt or response content, and no personal identifiers in metadata, fall into this index under your own configuration.

How a LiteLLM request reaches Elasticsearch

A client call goes to the LiteLLM proxy, which emits request logs, costs and latency over OTLP to an OpenTelemetry Collector. The Collector processes the records and hands them to an Elastic exporter, which writes them into the Elasticsearch data nodes that Kibana queries. Check each boundary: the gateway network, the Collector, and the Elasticsearch cluster each need their own authentication and network rules, and the Collector is where prompt content can be masked or dropped before storage.

Request logs flow from the gateway through a Collector into Elasticsearch, with trust boundaries marked.

Securing the logging path from gateway to index

Logs from the LiteLLM gateway to Elasticsearch cross several hops, and prompt content may sit in them. Each hop needs its own authentication, encryption and access decision, and the index needs read controls as strict as the gateway itself.

Authenticate incoming telemetry at the Collector

The OpenTelemetry Collector can check identity on connections it receives through authenticator extensions, for example OIDC. Decide which callers may send logs to the OTLP receiver, such as the LiteLLM host only, and reject anonymous senders. Confirm the authenticator and receiver components you plan to use in their README files, since Collector components carry mixed stability levels and some may not be ready for production.

Collector configuration docs

Authenticate outgoing exporter requests

The oauth2client extension adds credentials to requests the Collector sends onward, so the Elastic exporter does not need a shared password stored in plain configuration. Plan who issues the client credentials, how often they rotate, and how a revoked client is removed. Verify the exporter in your own environment, because the exact authentication options depend on the Elastic exporter version you deploy.

Least-privilege writer role in Elasticsearch

Create a dedicated Elasticsearch role and user for the Collector that can create and write only to the LiteLLM index pattern. It should not hold cluster administration, index deletion or read access to other indices. Separate the writer from the people who query the data, so a leaked Collector credential cannot read prompt history.

TLS on every hop

Encrypt the path from LiteLLM to the Collector, from the Collector to Elasticsearch and from Kibana to browsers. Use certificates issued by your internal authority and confirm that each client trusts that chain. Keep the Collector and Elasticsearch endpoints off public networks, and check that no hop falls back to plain HTTP in staging or in test configuration that later reaches production.

Keep the master key in a secret manager

LiteLLM's master key, which must start with sk-, and the Elasticsearch and Collector credentials should live in a secret manager, not in config files or container images. The production guide recommends this for the master key. Confirm which secret manager integrations your edition supports, and plan rotation for each credential that appears in the pipeline.

LiteLLM production guide

Restrict who reads prompt indices in Kibana

Prompt and response content in LiteLLM logs can be sensitive, so limit Kibana read access to named roles with document and field scope set to what each analyst needs. Field-level and document-level security sit in paid Elastic tiers, so confirm your subscription covers them before you rely on that control. Review who holds those roles on a set schedule.

Common failures when LiteLLM logs stop reaching Elasticsearch

This table lists the failures that most often stop LiteLLM logs from reaching Elasticsearch through the OpenTelemetry Collector, with the cause and the component-specific fix for each. Work through the rows in order when logs stop arriving, because the first two checks (endpoint and TLS) block everything downstream. The main takeaway is that most failures sit at the boundary between two components, so check the Collector's own logs before changing LiteLLM.

FailureLikely causeFix
Missing or wrong OTLP endpointLiteLLM sends telemetry to a host, port or path the Collector does not listen on, or the OTLP receiver is not enabled in the Collector configConfirm the receiver endpoint and port in the Collector's receivers section, then point LiteLLM's OTLP settings at that exact address and protocol
TLS or certificate mismatchThe Collector's Elastic exporter trusts a certificate authority that does not sign the Elasticsearch node certificate, or the hostname in the certificate does not match the endpointSet the exporter's CA file to the authority that issued the Elasticsearch certificate and match the endpoint hostname to a name on the certificate
Writer role lacks index creation rightsThe API key or user in the exporter can write documents but cannot create the index or its mapping, so the first bulk request failsGrant the writer role create_index and write privileges on the LiteLLM index pattern only, and confirm the rights with a test document before going live
Mapping conflicts from changed field typesA field such as cost or latency arrives as a string in one release and a number in another, so Elasticsearch rejects documents that do not match the existing mappingPin field types in an index template, rename the changed field, and create a new index with the corrected mapping instead of forcing a reindex of the old one
Unbounded index growthPrompt metadata and response bodies accumulate in one index with no lifecycle policy, so storage and query times rise over timeAttach an index lifecycle policy with rollover and deletion phases that match your retention decision, and keep prompt body fields out of long-retention indices
Dropped logs under loadThe Collector's batch or memory limiter processors shed data, or the Elastic exporter hits bulk rejections when Elasticsearch queues fillCheck the exporter's failed and refused counters, tune the batch and memory limiter settings, and size the Elasticsearch ingest capacity before raising LiteLLM traffic
Collector version driftThe Collector image or binary differs between environments, so a component that works in staging is missing or renamed in productionPin the Collector distribution and version in configuration as code, record the version in each change, and test each upgrade against the same LiteLLM sample traffic

Questions teams ask before connecting LiteLLM to Elasticsearch

What drives the effort and cost of connecting LiteLLM to Elasticsearch?

Internal staff time and the Elasticsearch footprint drive most of the cost, and the volume of prompt and response data drives the rest. Your team pays for the people who design the index mapping, run the OpenTelemetry Collector, and own the cluster. Elasticsearch cost depends on the subscription tier you need: the self-managed page lists Free and open (Basic), Platinum and Enterprise tiers, and notes that Platinum is no longer offered to new customers. Storage cost recurs with retention, so the longer you keep request records, the more you pay for hot and warm data. Ask any partner for a quote that separates one-time build work from recurring cluster and storage costs, and that states the retention period it assumes.

How long does it take to reach a verified LiteLLM to Elasticsearch pipeline?

The duration depends on how many environments you connect, whether an Elasticsearch cluster already exists, and how quickly your security and data owners agree on the index design. No timeline is set by the supplied sources, so confirm any duration in writing against a defined scope. To start, the team must provide access to the LiteLLM proxy configuration, an Elasticsearch cluster with credentials and role permissions, a written retention policy, and the field list your analysts need. Verification means showing that requests, costs and latency arrive in the expected indices with the fields and retention you specified, and that a failed Collector export is visible.

Can our team set up LiteLLM logging to Elasticsearch alone using the docs?

Yes, a team with Elasticsearch and OpenTelemetry experience can follow the LiteLLM Elasticsearch logging tutorial, which documents sending request logs, costs and performance data through an OpenTelemetry Collector with an OTLP receiver and an Elastic exporter. The harder work sits outside the tutorial: choosing index names and lifecycle policies, deciding which fields to keep, setting Collector authentication, and sizing the cluster. The OpenTelemetry Collector docs describe authenticator extensions for securing incoming and outgoing connections, which you will need to design. If those decisions are new to your team, a scoped implementation engagement can cover them with a written deliverable.

Should we store prompt and response bodies in Elasticsearch at all?

Store them only when a named use case requires it and your privacy and security owners have approved the data flow. Prompts often contain personal data, customer records or secrets, and every copy in Elasticsearch extends your retention and access obligations. Most teams start with metadata such as model, key, team, token counts, cost and latency, and add bodies later for a narrow set of teams. If bodies are needed, mask content before it reaches the logging path, restrict index access by role, and set a shorter retention period for those indices than for metadata. The LiteLLM documentation covers storing prompts in spend logs and per-team logging opt-outs, which you should review before you decide.

How should we separate indices and retention for LiteLLM data?

Use separate indices for metadata and for any prompt content, because the two groups usually need different access rules and different retention periods. Elasticsearch data nodes support hot, warm, cold and frozen tiers, so you can move older data to cheaper tiers instead of keeping everything hot. Write the retention period for each index in a policy your compliance owner signs off on before the Collector goes live. Confirm the exact lifecycle settings against the Elasticsearch version you run, because the supported release lines change over time.

Is OpenSearch a practical alternative to Elasticsearch for LiteLLM logs?

OpenSearch can be an alternative, but confirm the fit before choosing it. The OpenSearch FAQ states that OpenSearch is a fork of open source Elasticsearch 7.10, with OpenSearch Dashboards derived from Kibana 7.10.2, and that it is wire-compatible with Elasticsearch 7.10. That compatibility does not cover current Elasticsearch releases, and the LiteLLM tutorial targets an Elastic exporter, so check whether the exporter and the index features you need work with OpenSearch before you commit. Ask for a written compatibility test against your chosen version. If you want an OSI-approved license, note that Elastic offers AGPLv3 as an option alongside its Elastic License 2.0 default, so license choice is a separate decision from the product choice.

What do we need to ask a partner before agreeing to scope?

Ask for a written scope that lists the LiteLLM environments, the Elasticsearch cluster and tier, the Collector deployment model, the index and retention design, and the verification steps. Ask which costs are one-time and which recur, and what each depends on. Ask who holds administrative access to the Elasticsearch cluster and the Collector after handover, and what documentation you receive. Ask how the work handles prompt data, including masking and access controls. A clear written scope lets you compare a partner quote with the cost of doing the same work with your own team.

What to confirm with your own team before go-live

Confirm the Elasticsearch release line you will run and its end-of-maintenance date before you build anything. The supplied Elastic end-of-life dates cover the 8.x and 9.x core stack lines, but the dates that apply to your cluster are the ones on the Elastic product end of life dates page on the day you go live, and your own support contract may set different terms. Record the exact version, the date it leaves maintenance, and the upgrade window you have planned, because the Collector's Elastic exporter and your index templates both depend on that version. Also confirm your Elasticsearch license tier with Elastic, since security features such as single sign-on and field-level security sit in paid tiers.

Pin the LiteLLM release and the OpenTelemetry Collector release in writing, and check each against its supported-version statement. LiteLLM documents support for its four most recent stable minor versions, so confirm which minor line your gateway runs and when your upgrade plan moves it. Pin the Collector build you deploy, such as a specific contrib image tag, and verify its checksum and SBOM against the release artifacts before you admit it to your cluster. Check the Elastic exporter's stability level in the Collector component README, since component maturity varies. Record these pins in the same change record as the gateway configuration.

Classify the prompt data before you choose what the Collector exports. Ask your privacy, legal and security teams whether prompts and responses may leave the gateway, and whether they may be stored in Elasticsearch, which typically holds broader access than the gateway database. Decide whether bodies are logged at all, and if they are, who may query them and for how long. Name an owner for index lifecycle policies, covering rollover, hot, warm, cold and frozen phases, deletion and any legal hold, and agree that person's sign-off on retention periods. Finally, confirm who holds the Elasticsearch roles and API keys the Collector uses, because those credentials determine who can read prompt content.

How DeployOpen scopes and delivers LiteLLM logging to Elasticsearch

DeployOpen treats LiteLLM logs in Elasticsearch as a scoped delivery: the log fields, the OpenTelemetry Collector pipeline, the index design and the retention rules are agreed in writing before anything is built. The work runs in the client's own infrastructure, so the prompt data never leaves the environment the client controls.

How we scope

  • We agree in writing which LiteLLM callbacks, fields and cost data go to Elasticsearch and which are excluded.
  • We confirm the Elasticsearch deployment, license tier and the SSO and role model your security team requires.
  • We record index naming, retention periods and the decision on whether prompt bodies are stored at all.

How we build

  • We configure the OpenTelemetry Collector with an OTLP receiver and an Elastic exporter, with authentication on each hop.
  • We set up index templates, lifecycle policies and role-based access so each team sees only its own logs.
  • We test with sample traffic, including failed calls and budget events, and verify fields and costs match the gateway.

How we hand over

  • We document the pipeline, index design, retention settings and the steps to add a new team or log field.
  • We deliver a runbook covering Collector restarts, backpressure, mapping changes and version upgrades.
  • We walk your platform, security and compliance teams through the access model and the data retention rules.

How we support

  • Engagements are fixed-scope, and ongoing support, upgrades and continuous testing are available as a retainer.
  • We plan Collector and Elasticsearch upgrades against the supported release lines your team confirms.
  • We can retest the pipeline after changes to LiteLLM, the Collector or the index design.

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.