Monitoring Ollama usage and performance starts with the fields it already returns
Ollama's API responses already carry the token counts and timing fields you need to measure a shared server. The work is to collect those fields, store them and read them against the questions your teams ask. A shared Ollama server serving several teams has no built-in dashboard, so without this step, capacity planning becomes guesswork, chargeback has no basis, and slow-response complaints cannot be traced to a model, a time window or a load pattern. Teams usually need this measurement once more than one application or group depends on the same server. Ollama is MIT licensed and runs on infrastructure you control, so the collection layer can be built in your own environment without a license fee for the runtime. Ollama also states that local runs do not see your prompts or data, which means the metrics you store are yours to govern.
Start by making a non-streamed request to the local API and reading the final JSON object. Confirm the exact field names and units for your installed version in the API reference, because they are documented per endpoint and can differ between streamed and non-streamed responses. In most builds the fields to look for are prompt_eval_count and eval_count for tokens, and total_duration, load_duration, prompt_eval_duration and eval_duration for time. Record the model name with each record, since tokens per second and load time vary by model. Attribute usage to a team or key at the gateway or application layer, not in Ollama, because the local API does not require authentication and carries no caller identity of its own. Before you build dashboards, run one controlled request per model and confirm that your collector stores every field.
Metric collection options and when each fits
This table compares collecting metrics from raw Ollama API responses, placing a gateway in front of Ollama, and sending traces to self-hosted Langfuse through OpenTelemetry. Read each row against the server settings that bound concurrency, since OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS and OLLAMA_MAX_QUEUE determine what the numbers mean. The main takeaway is that raw responses are cheapest to start with, while per-user attribution usually requires a layer that sees the caller's identity.
| Option | What it captures per request | Setup effort | Per-user attribution trade-off |
|---|---|---|---|
| Raw API response fields | Prompt and completion token counts, total duration, load duration and eval timings for each call | Low. Parse fields in your client or a script and store them in your own system | Weak. Ollama's local API does not authenticate callers, so requests can only be tied to users if your client adds that identity |
| Gateway in front of Ollama (LiteLLM or APISIX) | Caller identity, model, token usage and latency at the proxy, plus any errors or rejections returned to clients | Medium. Requires routing, authentication and logging configuration, and an ongoing gateway to maintain | Strong. Keys or consumer identities at the gateway can be recorded against each request, but only for traffic routed through it |
| Traces to self-hosted Langfuse via OpenTelemetry | Spans per request with model, token usage and timing, linked to application traces and user or session tags you send | High. Needs Langfuse deployed with PostgreSQL, ClickHouse, Redis or Valkey and blob storage, plus instrumentation in each client | Depends on tags your application sends. Attribution is only as reliable as the identifiers instrumented in the client |
| Server settings as context | OLLAMA_NUM_PARALLEL sets parallel requests per model (default 1), so queue time can rise even when generation speed is normal | Configuration change on the server, applied at service restart | Concurrency limits affect every caller equally, so per-user numbers must be read alongside shared queue behavior |
| OLLAMA_MAX_LOADED_MODELS | Caps how many models stay resident (default 3 times the GPU count, or 3 on CPU), so frequent load events can inflate load time | Configuration change on the server | Model swapping caused by many users can make one user's latency depend on another's requests |
| OLLAMA_MAX_QUEUE | Caps queued requests (default 512). Requests beyond the limit are rejected, so rejections appear as errors rather than slow responses | Configuration change on the server | Queue position is shared, so per-user timing mixes your own wait with other users' load. Confirm the rejection behavior in your version |
| Choosing between them | Use raw fields for a small team, a gateway when you need per-caller limits and records, and Langfuse when you also need trace-level analysis across applications | Start with raw fields, then add a layer once attribution or retention becomes a requirement | Confirm which identity each layer receives before reporting per-user figures to auditors or managers |
How to set up collection on a shared Ollama server
This sequence turns a shared Ollama server into a measured service. It secures the metrics path, records token and timing fields for each model and user, derives tokens per second per model, and ends with totals checked against a workload you ran yourself.
Confirm the bind address and API exposure
The platform engineer checks the value of OLLAMA_HOST on the server. By default Ollama listens on 127.0.0.1 port 11434, and the local API does not require authentication, so anything that can reach that port can send requests. If the metrics collector runs on another host, place it behind a reverse proxy or gateway that enforces access, then confirm from a user network that port 11434 does not answer. This step is done when the collector can read metrics and an unauthorized host receives no response.
Capture a baseline from each model
The team sends the same short, fixed prompt to every model the server hosts, using the native API with streaming turned off, and saves each full JSON response. The response includes token counts and timing fields that show how long the model spent loading and how long it spent generating. Run ollama ps during the baseline to confirm which models were resident, and store the results with the server configuration. This step is done when every installed model returns a complete set of fields and the baseline file is saved for later comparison.
Store token and timing records with metadata
The platform team defines one record per request containing the model name, a user or API key identifier, a UTC timestamp, the prompt token count, the output token count, the load duration, the prompt evaluation duration and the generation duration. The Ollama response does not identify the caller, so the identifier has to come from the layer that forwards the request, such as a gateway or application logs. Write the records to a database or log store the team can query. This step is done when a test request produces one record with every field populated and the user identifier matches the test caller.
Compute tokens per second for each model
The team divides the output token count by the generation duration for each record and reports the result grouped by model. Load time is excluded so that cold starts do not distort throughput, and the first request after a model loads is kept in a separate group. Confirm the unit of each timing field in the API reference before writing the calculation. This step is done when the value calculated for the baseline prompt matches a manual calculation from the saved JSON and the query returns one throughput figure per model.
Add gateway or Langfuse tracing for attribution
Where reports must show usage per person, team or application, route calls through an AI gateway such as the LiteLLM proxy, or instrument the application with OpenTelemetry and send traces to a self-hosted Langfuse deployment. Both approaches record which caller made each request, which the bare Ollama API does not. Core Langfuse features are available under the MIT license, but some governance features need an Enterprise license key, so confirm the scope with license key requirements before you commit. This step is done when a request from each test caller appears in the gateway or trace view with its identifier and token counts.
Verify totals against a known test workload
The team runs a scripted workload with a known number of requests per model, a fixed prompt set and known caller identifiers, then compares the stored totals with the expected counts. Gaps usually come from retries, failed requests, streaming responses that were not fully parsed, or requests that bypassed the gateway. Investigate each difference and fix the collector before the numbers go into any report. This step is done when request counts, token totals and per-user attribution match the script's expected values for every model, and the check passes again after a configuration change.
How requests and metrics flow from clients to storage
The diagram starts with client applications calling a gateway or proxy, which forwards requests to the Ollama API on localhost port 11434 inside the trust boundary of the Ollama host. The Ollama response carries token counts and timing fields that the gateway or application can record. Optional OpenTelemetry traces can be sent to a metrics store or to a self-hosted Langfuse instance. Check which component is the only one allowed to reach the Ollama port, and confirm where prompts and traces are stored.
Client requests pass through a gateway to Ollama, and usage data flows to storage.
When to add Langfuse and when the API fields are enough
When a small team runs one Ollama server, the timing and token fields in each API response often answer the questions that matter: whether a model loads slowly, how many tokens a request generated and what throughput a model reaches on your hardware. A short script or a log line per request is usually enough to start. Adding a self-hosted tracing platform at this stage means running several stateful services for a handful of users, which rarely pays off.
- Load versus generation time: Compare the model load duration with the generation duration in each response to see whether cold loads or generation drive latency.
- Tokens per second: Derive throughput per model from the token count and eval duration fields, and track it over time for the same prompt sizes.
- Request volume: Count requests per model and per hour from your own access logs before adding any new system.
- Operational overhead: A tracing platform adds databases, storage and upgrades that someone on the team must own.
- Local data handling: Ollama states that local runs do not send your prompts to it, so logging stays inside your environment.
Before adding anything, confirm that the fields your Ollama version returns cover the questions your team actually asks.
When several teams share one Ollama server, the question changes from how fast is the server to who used it and what did it cost in capacity. Raw API fields do not attribute requests to a team, user or application unless you add that tagging yourself. A gateway in front of Ollama can record caller identity, but Langfuse adds trace-level views, sessions and dashboards that teams can browse without building their own reporting.
- Per-team views: Tag traces with user, team or application identifiers so usage can be grouped by owner.
- Gateway or SDK instrumentation: Decide whether attribution comes from a gateway such as one you already run, or from application code that sends traces.
- Dashboards and sessions: Langfuse offers trace exploration and dashboards on the open source core, which avoids building custom reports.
- Access separation: Project-level role control is part of the Enterprise license, so confirm whether a shared open source deployment is acceptable for your team boundaries.
- Capacity planning: Pair usage data with the concurrency settings on the server so you can see when queueing starts.
Ask your team leads which usage questions they need answered each month, then test whether the API fields and a gateway can answer them.
In a regulated environment, the need for retention periods, audit trails and controlled access usually decides the tooling. The Langfuse core is MIT licensed, but several controls that regulators and internal audit ask about, including audit logs, data retention policies, server-side data masking and RBAC roles, need an Enterprise license key on self-hosted deployments. Plan that cost and approval early, because the licensing decision affects what you can show an assessor.
- License key features: Audit logs, retention policies, server-side masking, RBAC and SCIM provisioning require a license key on self-hosted Langfuse.
- Self-hosted components: A deployment needs PostgreSQL, ClickHouse, Redis or Valkey, and S3-compatible blob storage, each of which needs its own backup, patching and access controls.
- Data minimization: Decide what prompt and response content is stored at all, and whether masking happens before data leaves the application.
- Evidence: Retention and audit settings are only useful if you can show their configuration and logs over time.
- Scope: DeployOpen prepares systems and evidence for assessments, but independent auditors issue any formal opinion.
Confirm the license terms, data categories and retention requirements with your compliance team before choosing between the API fields and a self-hosted tracing platform.
Security risks in collecting usage data from Ollama
Collecting usage data from a shared Ollama server creates new places where prompts, completions and user identities can leak. The risks below sit in the local API, the telemetry pipeline and the dashboards that display it, so each one needs a control of its own.
Prompts and completions stored in traces
Tracing tools often record the full request and response body by default, so a prompt that contains patient, customer or source-code content ends up in a trace store. Decide per route whether content capture is on, and mask or drop message bodies before they leave the gateway. Check that only token counts and timing fields are kept for routine performance monitoring.
Langfuse OpenTelemetry docsUnauthenticated access to the local API
The local Ollama API at port 11434 does not require authentication. If a bind address is widened with OLLAMA_HOST and no proxy sits in front, anyone who can reach the port can send prompts, pull models and read usage responses. Confirm the listener address with your network team and place an authenticating gateway in front of every exposed route.
Metric endpoints exposing usage by user
A metrics or usage endpoint that labels series with user, API key or prompt source can reveal who uses which model and how often. That data may be sensitive in its own right, even when no prompt text is captured. Limit scrape access to the monitoring network, and remove identifying labels that the dashboards do not need.
Retention of logs containing sensitive content
Debug logs, proxy access logs and trace exports often outlive the purpose that justified them. Set a written retention period for each store, and confirm that the periods match your data handling policy. Enable OLLAMA_DEBUG only for short troubleshooting windows, because debug output can expose more request detail than normal operation.
Access to Langfuse dashboards
A self-hosted Langfuse instance shows traces, users and sessions to anyone with a login. Some governance features, such as project-level RBAC roles, audit logs and server-side data masking, need an Enterprise license key. Confirm which roles your organization needs before inviting users, and test that a read-only account cannot view raw message content.
Langfuse license key docsCloud features and the data boundary
Ollama states that when it runs locally it does not see your prompts or data, and cloud features can be turned off with OLLAMA_NO_CLOUD=1 or the server configuration file. Set this variable on servers that must stay offline, then verify with a test request that no outbound cloud call is made. Keep cloud keys out of the collection pipeline unless the data is approved for that path.
Questions teams ask before measuring Ollama usage
Does measuring Ollama usage cost money?
Ollama itself costs nothing to run on your own hardware. The pricing page states that running models on your own hardware is always unlimited, and the runtime is MIT licensed. The costs come from what you add around it: a collection and visualization layer, storage for the metrics, compute to run that layer, and staff time. If you use a self-hosted Langfuse deployment, the open source version includes all core features and APIs without limits, while some features such as RBAC roles, audit logs and data retention policies need an Enterprise license key. Ask any partner to separate one-time setup costs from recurring hosting and licensing costs in the quote.
What drives the cost of a usage monitoring setup?
Four things move the cost most. The first is the tooling you choose, since a metrics gateway, a tracing tool or a custom script each carry different build and run effort. The second is storage and analytics capacity: a self-hosted Langfuse deployment runs PostgreSQL, ClickHouse, Redis or Valkey and S3-compatible blob storage, and Langfuse's scaling guide lists minimum resources of 2 CPU and 4 GiB for web, worker and PostgreSQL, and 2 CPU and 8 GiB for ClickHouse, with at least 16 GiB of ClickHouse memory for larger deployments. The third is retention length and request volume, which set how much data you keep. The fourth is staff time for dashboards, alerts and upkeep. Larger volumes and longer retention raise the storage and compute line.
How long does it take to set up usage monitoring?
The duration depends on scope: whether you only read token counts and timing fields from API responses, or also deploy a gateway, a tracing tool and dashboards. Reading the native timing fields needs no new infrastructure and can start immediately, while a full pipeline with a backend, retention settings and access controls takes longer to plan and test. No fixed timeline is given here, so ask a partner to state the duration in the written scope, including the number of models, environments and integrations covered. Fixed-scope engagements agree deliverables and timelines in writing before work starts.
What does our team need to provide for this work?
You need to provide access and decisions. That means a running Ollama server you can query, a place to deploy the collection stack inside your own infrastructure, and named owners for the metrics. Owners should decide which fields matter, who may see per-user or per-model data, and how long records are kept. Your security team should confirm where the data is stored, because Langfuse documents Docker Compose on a single VM for testing with no high availability, and Kubernetes with Helm or Terraform for production. Your platform team should also confirm network paths, since Ollama's local API has no authentication by default and is bound to 127.0.0.1 port 11434 unless you change OLLAMA_HOST.
Can our own team measure Ollama usage without a partner?
Yes, a capable platform team can start by reading the token counts and timing fields that Ollama returns in API responses and logging them to a file or existing system. This gives you load time, generation time and tokens per second per model without new software. A partner adds value when you need a gateway with per-user attribution, a tracing backend with access control, or a production deployment that must be backed up, upgraded and reviewed by your compliance team. Decide early whether your team has the time to run that stack for the long term, because upgrades and retention work recur. A quote from a partner should list what your team keeps after handover.
What should we ask a partner to include in a quote?
Ask for a written scope that lists each deliverable, such as the metrics you will collect, the dashboards and alerts, and the tools chosen. Ask which costs are one-time, including design, installation and testing, and which recur, including hosting, storage growth, licensing, upgrades and support. Ask how capacity is sized for ClickHouse and worker containers, and what retention period is assumed. Ask who is responsible for backups, version upgrades and security patches after handover. Also ask what the partner will not cover, such as audit evidence, which independent auditors and certification bodies issue rather than DeployOpen. Confirm the support model, including whether a retainer is needed.
Does measuring usage send our prompts to a third party?
It depends on where you send the data. Ollama states that when it runs locally it does not see your prompts or data, and cloud features can be turned off with OLLAMA_NO_CLOUD=1 or in the server configuration file. A tracing tool you host yourself keeps trace data inside your infrastructure, but you still need to decide what content is logged. Many teams record token counts and timings without storing prompt text, and apply server-side data masking where the tool supports it, which Langfuse lists as an Enterprise license feature. Confirm these choices with your security and privacy teams before any prompt content reaches a metrics store.
What happens to the monitoring stack when we upgrade?
Upgrades affect the monitoring layer as well as Ollama. Ollama releases are frequent, and v0.40.5 was released on 14 October 2026, so pin versions and test changes before rollout. For a self-hosted Langfuse deployment, Langfuse says updates within a major version are non-disruptive and run database migrations automatically at startup. Major upgrades follow dedicated migration guides. The v3 to v4 guide requires ClickHouse 25.12 or later, PostgreSQL 15 or later and Redis 7.0 or later, and advises about 3x ClickHouse disk headroom when backfilling historic data. Plan that headroom in your storage budget.
How DeployOpen scopes and delivers Ollama monitoring
DeployOpen plans, implements, hardens and documents monitoring for a self-hosted Ollama server inside your own infrastructure, so the metrics, logs and dashboards stay under your control. The work usually starts with a written scope that names which signals to collect, where they are stored, who reads them and which API consumers are in the measurement path. Because Ollama's local API has no built-in authentication, the scope also has to decide whether requests pass through a gateway that can attribute usage to a user or application, and that decision changes what can be measured at all.
A typical engagement covers the parts this topic depends on: confirming which fields your clients receive from the API, deciding where timing and token counts are captured, placing a collector or gateway in front of the server, and setting up dashboards for tokens per second by model and load time against generation time. DeployOpen also documents the runbook so your platform team can answer routine questions after handover. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, and the quote follows from that written scope. Ask for the deliverables list, the environments covered, the access DeployOpen needs and who owns the resulting configuration.
Ongoing support is available through retainers, which suit monitoring because the Ollama release cadence and the metrics you rely on change over time. Before you request a quote, confirm internally who will be paid for what: DeployOpen for the design and build, your staff or a retainer for the monitoring you run each day, and any separate tooling licenses you choose. DeployOpen does not publish a price list and does not issue audit reports or certifications, so any evidence you need for a compliance review should be scoped as preparation work in the same written agreement.

