What to Measure: Metrics, Dashboards and SLOs

You cannot fix what you cannot see. Measure outcomes first, then the steps, tokens and time behind them.

BeginnerIntermediateExpert · 12 min read · Last updated:

In short

Observability is being able to work out what your system did, and why, from what it records. For agents, watch five things together: task success, latency, cost and tokens, errors and safety events. Set targets for the ones users feel, and alert when you are using up the allowed failures too fast.

What you will learn: what to record, how to define and calculate key measures, dashboard design, objectives and alerts, a metrics reference, standard naming and a reference architecture.
Prerequisites: The Agent Loop: Observe, Reason, Plan, Act, Reflect. Running a web service helps but is not required.

Beginner What to watch and why

Why agents need more than uptime

An ordinary service that responds quickly without errors is probably working. An agent can respond quickly, return success and still have done the wrong thing. It can also quietly take twice as many steps after a change, doubling cost while every dashboard of server health stays green.

Signal typeAnswersExample
MetricsHow much and how often?Success rate, slow-end latency
TracesWhat happened in this run?Plan, model call, tool call, result
LogsWhat details were recorded at a moment?"Approval refused by policy rule 7"
EvaluationsWas it good?Sampled grade for grounding

Metrics tell you something is wrong, traces show where and logs and grades explain why. Tracing is covered in Agent Tracing and OpenTelemetry.

The measures that matter

AreaCore measures
OutcomeTask success, escalation rate, human correction rate, repeat contact
LatencyTotal time, time to first output, time per step, at median and slow end
CostInput and output tokens, cached tokens, cost per run and per successful task
ReliabilityError rate by type, timeouts, retries, limit stops
BehaviorSteps per task, tool calls per task, loop detections
SafetyBlocked actions, refused approvals, access denials, guardrail triggers
CapacityConcurrent runs, queue age, rate-limit responses

Use percentiles, not only averages

If nine runs take 3 seconds and one takes 63, the average is 9 seconds, a number nobody experienced. The median (p50) shows the typical case; p95 or p99 shows the unlucky one. Agent latency often has a long tail, because a few runs take many more steps. Do not average percentiles from separate servers; compute them from the underlying data or from histograms.

Define each measure precisely

"Success rate" can mean five different things. Write down the numerator, the denominator and the exclusions.

MeasureDefinition to agree
Task successTasks verified complete ÷ tasks started, including abandoned ones
Cost per successful taskAll spend, including failures and retries ÷ successful tasks
Escalation rateTasks passed to a person ÷ tasks started
Tool error rateFailed calls ÷ attempted calls, per tool
Limit-stop rateRuns ended by step, time or budget limits ÷ runs

Where success cannot be verified automatically, use a proxy, label it as a proxy and check it regularly against graded samples.

What to record for every run

Good measures start with one well-formed record per run and one per step. If these fields exist, most charts are simple queries.

FieldWhy you will want it
Run id, session id and trace idJoin metrics to the story of one run
Agent, release, prompt and model versionsTie a change in numbers to a change in the system
Task type and user groupFind who is affected
Start, end and time waiting for peopleSeparate system delay from human delay
Token counts per model callCalculate cost and spot context growth
Tool name, outcome and error class per callLocate failing integrations
End reasonCompleted, escalated, limit reached, failed or canceled
Outcome verdict and who judged itDistinguish verified success from assumed success

The end reason is small and valuable. A rising share of runs stopped by a step limit is often the earliest sign that something changed, well before users complain.

Intermediate Calculate, display and alert

From run records to decisions

This program creates 400 synthetic run records in which a tool starts failing in the last quarter. It calculates success, latency percentiles, cost per success and error budget burn. The data and prices are invented for the example.

"""Turn run records into the numbers a dashboard and an alert need."""
import math
import random
from collections import Counter

rng = random.Random(11)
RUNS = []
for i in range(400):
    bad_hour = i >= 300                      # a tool starts failing late in the day
    tool_error = rng.random() < (0.20 if bad_hour else 0.02)
    ok = not tool_error and rng.random() < 0.97
    RUNS.append({
        "ok": ok,
        "error": "tool_timeout" if tool_error else (None if ok else "wrong_result"),
        "seconds": rng.lognormvariate(1.6, 0.5) + (12 if tool_error else 0),
        "in_tok": rng.randint(4000, 12000), "out_tok": rng.randint(300, 900),
    })
PRICE_IN, PRICE_OUT = 3.0, 15.0              # example prices per million tokens
SLO = 0.95                                   # target share of successful runs


def percentile(values, q):
    ordered = sorted(values)
    return ordered[max(0, math.ceil(q * len(ordered)) - 1)]


def summary(runs):
    good = sum(r["ok"] for r in runs)
    cost = sum(r["in_tok"] * PRICE_IN + r["out_tok"] * PRICE_OUT for r in runs) / 1e6
    secs = [r["seconds"] for r in runs]
    return {"success": good / len(runs), "p50": percentile(secs, 0.50),
            "p95": percentile(secs, 0.95), "per_success": cost / good,
            "burn": (1 - good / len(runs)) / (1 - SLO)}


for label, runs in [("all day", RUNS), ("first 300", RUNS[:300]), ("last 100", RUNS[300:])]:
    s = summary(runs)
    print(f"{label:9}  success {s['success']:.1%}  p50 {s['p50']:.1f}s  p95 {s['p95']:.1f}s"
          f"  ${s['per_success']:.4f}/success  burn {s['burn']:.1f}x")
print("errors:", dict(Counter(r["error"] for r in RUNS if r["error"])))
long_burn, short_burn = summary(RUNS[-100:])["burn"], summary(RUNS[-25:])["burn"]
print("page on-call" if long_burn > 2 and short_burn > 2 else "no page")

Output:

all day    success 88.8%  p50 5.3s  p95 16.4s  $0.0371/success  burn 2.2x
first 300  success 95.0%  p50 5.0s  p95 13.8s  $0.0342/success  burn 1.0x
last 100   success 70.0%  p50 6.6s  p95 17.8s  $0.0489/success  burn 6.0x
errors: {'tool_timeout': 33, 'wrong_result': 12}
page on-call

Compare the first line with the other two. The all-day figures show a mild problem. Split by time, they show a healthy period followed by a severe failure that raised the cost of each successful task. Always be able to cut measures by time, version, tool, model and customer group.

Tokens, latency, cost and errors

Tokens and cost

  • Record input, output and cached input tokens separately from the provider's response, because prices usually differ.
  • Attribute cost to a task, feature, version and team.
  • Include other charges: retrieval, hosted tools, compute and human review time.
  • Watch tokens per step. A growing context is a common cause of rising cost.

Store the token counts and calculate money from a versioned price table, so history stays correct when prices change.

Latency

Break the total into queue wait, context building, model time, tool time and approval wait. Show approval wait separately; it is human time and would otherwise hide system slowness.

Errors

Use a small, fixed set of error classes, such as model error, rate limit, tool timeout, invalid arguments, policy refusal, limit stop and wrong result. Free-text messages are for logs. A refusal by policy is not a fault, so chart it apart, but do notice when it jumps.

Questions your data should answer

QuestionWhere to lookLikely causes
Why did cost rise overnight?Tokens per step, steps per run, volume by featureLonger tool results, a loop, a new model, more traffic
Why is it slow for some users?Slow-end latency by tool, region and task typeOne slow service, large documents, rate limiting
Why did success fall after a release?Success by version and task type; failed tracesPrompt wording, tool description, model behavior
Is someone abusing the system?Spend and refusals by user; unusual destinationsScripted use, injection attempts

Try these questions against your telemetry before an incident. Each one you cannot answer names a missing field.

Production dashboards

OverviewSuccess, latency, cost and safety against targets
BreakdownBy agent, version, model, tool and user group
TracesIndividual runs behind any point on a chart
DashboardAudienceContents
Service healthOn-call engineerObjectives, error budget, errors by class, queue age, recent releases
QualityProduct and domain ownersVerified success, sampled grades, escalations, corrections
CostOwners and financeSpend by feature, cost per success, tokens per step, top consumers
SafetySecurity and riskBlocked actions, unusual destinations, access denials, approval patterns
Tool healthIntegration ownersCalls, errors, latency and rate limits per tool

Mark releases, prompt changes and model changes on every time chart. Put the target on the chart. Remove panels nobody has used to make a decision.

Service level objectives

A service level indicator is a measurement, such as the share of tasks completed correctly. A service level objective (SLO) is the target for it over a period. The allowed shortfall is the error budget. Google's site reliability engineering book explains the approach.

Illustrative objectiveWindow
95% of tasks are verified successful or correctly escalated28 days
95% of interactive runs finish within 20 seconds, excluding approval wait28 days
99% of accepted background jobs finish within 1 hour28 days
Cost per successful task stays within the agreed ceiling7 days

Choose targets from what users need and what you can measure, starting from your observed baseline. Do not express a safety rule such as "no unauthorized actions" as a percentage with a budget. Enforce it, and treat any breach as an incident.

Expert Alerting, reference and architecture

Alerting on burn rate

The burn rate says how fast you are using the error budget. A rate of 1 spends exactly the budget over the window; a rate of 6 spends it six times as fast. Alerting when burn is high over both a longer and a shorter window catches serious problems quickly and stops alerting soon after recovery. The program above pages only when both its windows exceed twice the budget rate. Real thresholds and windows depend on your objective and traffic.

SituationResponse
Fast budget burnPage the on-call person
Slow, steady burnCreate a ticket for working hours
Safety or access violationPage immediately, regardless of volume
Spend far above forecastAlert owner; apply a cap if agreed
Quality grade drifting downReview with the product owner

Every alert needs an owner, a runbook link and an action someone can take. With little traffic, percentages swing wildly, so require a minimum number of events or use synthetic checks.

Error budget arithmetic

With a 95% objective, 5% of tasks may fail within the window. Over 100,000 tasks that is 5,000 failures. If 2,500 have happened a quarter of the way through, half the budget is gone with three quarters of the time left, which calls for attention even if nobody has complained. Agree in advance what a spent budget means, for example pausing risky changes until reliability recovers. An objective with no consequence is only a chart.

Metrics reference

MetricTypeUseful labels
Runs started and endedCounteragent, version, end reason
Run durationHistogramagent, version
Model call duration and first-output timeHistogrammodel, operation
Tokens usedHistogram or countermodel, input or output
Tool calls and durationCounter, histogramtool, outcome, error class
Steps per runHistogramagent, version
ApprovalsCounter, histogram of waitaction type, decision
Policy blocksCounterrule
Queue depth and oldest job ageGaugequeue
Keep labels bounded

Never use user ids, run ids or free text as metric labels. Each new value creates a new series and can overwhelm a metrics system. Put identifiers in traces and logs instead.

Standard names

OpenTelemetry publishes semantic conventions for generative AI, marked as in development at the time of writing, so names may still change. Examples include:

NameMeaning
gen_ai.client.token.usageMetric: tokens used
gen_ai.client.operation.durationMetric: duration of a model operation
gen_ai.operation.nameAttribute: kind of operation, such as chat or execute_tool
gen_ai.provider.nameAttribute: which provider
gen_ai.request.modelAttribute: requested model
gen_ai.agent.name, gen_ai.tool.nameAttributes: which agent and tool

Following shared names makes it easier to change tools and compare teams. Record which version of the conventions your instrumentation uses.

Reference architecture

Instrumented runtimeAgent loop, model client and tools emit spans, metrics and logs
CollectorRedact sensitive values, add context, sample, route
Metrics store
Trace store
Log and audit store
UseDashboards, alerts, debugging, evaluation, cost reports
  • Count metrics for all runs, even when you keep only some traces.
  • Keep all traces that failed, were blocked or were very slow or costly, plus a sample of normal ones.
  • Decide before launch whether prompts and outputs are stored, who can read them and for how long: see Safe Logging, Sampling and Retention.
  • Keep audit records of actions separate from debugging logs, and protect them from change.
  • Make sure telemetry failure never stops the agent, and that missing telemetry raises its own alert.

A weekly routine

  1. Compare objectives and error budget with last week.
  2. Look at the largest changes in cost per success and steps per task.
  3. Read ten failed traces and five random successful ones.
  4. Add recurring failures to the evaluation suite: see Continuous Evaluation, Statistics and Scorecards.
  5. Remove or fix one noisy alert.
Expert tip

Read some successful traces. Wasted steps, risky near misses and lucky guesses hide inside runs that every dashboard counts as good.

Observability checklist

  • Success is defined and measured, not assumed from HTTP status
  • Every run has one id across model calls, tools and agents
  • Tokens, latency and errors are recorded per step
  • Releases and model changes appear on charts
  • Objectives have owners and error budgets
  • Alerts lead to an action and a runbook
  • Sensitive data is redacted and retention is set

Frequently asked questions

Do I need a special agent monitoring product?

Not to start. Structured logs, standard tracing and a dashboard cover much. Specialized tools add trace viewing and evaluation workflows.

Should I store full prompts?

Only with a clear purpose, access control and retention limit. They often contain personal or confidential data.

How do I measure success without ground truth?

Combine system outcomes, user behavior and graded samples, and state the uncertainty.

What should I build first?

A run id, a trace of every step, token and error counts, and one verified outcome measure.

References and further reading

Next steps