LLM Monitoring in Production: Metrics, Quality, Cost, Safety
LLM monitoring in production: SLIs for latency, errors, tokens, groundedness and safety, plus observability alerts that catch quiet quality decay early.
This article is published in English.
Sources: LLM Monitoring in Production: Metrics, Quality, Cost, and Safety
This walkthrough rebuilds the path from raw materials to a working system for: LLM Monitoring in Production: Metrics, Quality, Cost, and Safety. The focus is operable steps, explicit checks, and code that you can drop into a repo without guessing intent. For Overview, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
An LLM application is not just a model call
For An LLM application is not just a model call, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Track latency, error rate, token cost, groundedness, and safety hits as first-class SLIs.
Begin with normal production monitoring
For Begin with normal production monitoring, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Track latency, error rate, token cost, groundedness, and safety hits as first-class SLIs.
The monitoring stack that actually matters
For The monitoring stack that actually matters, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Track latency, error rate, token cost, groundedness, and safety hits as first-class SLIs. For The monitoring stack that actually matters, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Cost per request is often the wrong metric
For Cost per request is often the wrong metric, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode.
Record enough context to reproduce a failure
For Record enough context to reproduce a failure, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode.
trace_id
request_id
session_id
timestamp
application_version
prompt_template_id
prompt_template_version
retrieval_pipeline_version
tool_schema_version
requested_model
returned_model
generation_parameters
input_tokens
output_tokens
time_to_first_output
total_generation_time
total_request_time
retrieval_query
retrieval_filters
retrieved_document_ids
retrieved_document_versions
retrieval_scores
reranker_scores
tool_name
tool_status
tool_duration
tool_retry_count
tool_side_effect_id
input_guardrail_result
output_guardrail_result
policy_reason
quality_scores
human_review_status
user_feedback
task_outcome
Do not turn observability into a privacy leak
For Do not turn observability into a privacy leak, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode. For Do not turn observability into a privacy leak, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Quality cannot be reduced to one universal score
For Quality cannot be reduced to one universal score, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Sample traces into an evaluation set so production surprises become offline tests.
Use LLM judges, but do not worship them
For Use LLM judges, but do not worship them, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Sample traces into an evaluation set so production surprises become offline tests.
Retrieval and generation must be monitored separately
For Retrieval and generation must be monitored separately, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Measure recall on a fixed question set before tuning prompts. Prompt churn rarely fixes a weak retrieval surface. For Retrieval and generation must be monitored separately, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Agent monitoring is action monitoring
For Agent monitoring is action monitoring, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.
User feedback is useful, but noisy
For User feedback is useful, but noisy, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Track latency, error rate, token cost, groundedness, and safety hits as first-class SLIs.
Monitor slices, not just global averages
For Monitor slices, not just global averages, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Separate chunking policy from retrieval policy. Changing one should not force a rewrite of the other when quality metrics move. For Monitor slices, not just global averages, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Alerts should lead to decisions
For Alerts should lead to decisions, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode.
Define LLM service-level objectives
For Define LLM service-level objectives, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode.
Build monitoring and evaluation as one feedback loop
For Build monitoring and evaluation as one feedback loop, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode. For Build monitoring and evaluation as one feedback loop, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
A practical rollout plan
For A practical rollout plan, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Sample traces into an evaluation set so production surprises become offline tests.
The real purpose of LLM monitoring
For The real purpose of LLM monitoring, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Sample traces into an evaluation set so production surprises become offline tests.
Operational checklist
For Operational checklist, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state.
Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.
Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode.
Write a short runbook: how to rotate keys, how to drain the queue, how to roll back the last ingest.
Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Alert on distribution shift, not only hard failures. Quiet quality decay is the expensive failure mode.
Before promoting the stack, freeze versions, capture a golden transcript for the critical path, and confirm rollback steps. Shared environments need rate limits, tenancy checks, and a clear owner for secret rotation. Prefer boring reliability over clever one-off demos.
For hardening note 0, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.
For hardening note 1, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.
For hardening note 2, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline.
For hardening note 3, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.
For hardening note 4, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.