kagent
All build guides
VerifiedIntermediate15 min

Observing and Evaluating Agent Workloads on Kubernetes

Collect traces, metrics and logs from kagent and Agent Substrate through one OpenTelemetry Collector, and score agent runs with agentevals.

By kagent maintainers
  • #observability
  • #opentelemetry
  • #agentevals

Updated: December 1st, 2026

Built against: kagent 1.0.1, Agent Substrate 1.0.1, agentevals 0.15.1

Introduction#

An agent's turn on Agent Substrate passes through the kagent controller, Substrate's ingress gateway, the agent's own actor, and Substrate's egress gateway before it reaches a model or a tool. Each of those writes its own telemetry, and none of it is collected until you say where it goes.

This guide sends traces, metrics and logs from kagent and Agent Substrate through one OpenTelemetry Collector. Tempo stores the traces, Loki the logs, and kube-prometheus-stack runs Prometheus and Grafana. agentevals scores the agent runs and sends each score back through the Collector as a log event.

kagent controller + agents ─┐ ┌─> Tempo (traces)
Substrate (api, controller, ├─> otel-collector ├─> Loki (logs)
atelet, workers, │ (telemetry) ├─> Prometheus (metrics, scraped on :8889)
router, egress) ─┘ ▲ └─> agentevals (agent turns only)
│ │
└── scores, as log events

What goes wrong without it#

Each of these is addressed by a step in this guide.

  • Nothing is collected until you say where. The kagent chart ships config.telemetry: {} and the Substrate chart otel.endpoint: "". Every component can export OTLP, and none does.
  • Substrate keeps one trace in a hundred. Its chart samples traces at 0.01 by default, so most turns leave no Substrate spans at all.
  • A turn is spread across components. The controller, the gateways, Substrate's API and the agent runtime each record their own part. Without one pipeline that keeps the trace ID, following a slow turn means reading several logs side by side.
  • Prometheus does not find Substrate's gateways. The ingress gateway carries a prometheus.io/scrape annotation, and kube-prometheus-stack ignores annotations.
  • A trace says what an agent did, not whether it was right. The same agent, asked the same thing twice, can call different tools and give different answers. Nothing in a trace scores that.

What you will build#

  • One OpenTelemetry Collector that receives every signal from kagent and Agent Substrate
  • Tempo for traces, Loki for logs, Prometheus for metrics, and Grafana with all three as data sources
  • A turn-duration metric derived from each agent's invoke_agent span
  • Prometheus scraping Substrate's ingress and egress gateways, and the kagent controller
  • agentevals receiving agent turns only, and scoring one session against another
  • Every score in Loki, carrying the trace and span ID of the turn it scored

How this guide is organized#

Up and Running installs the stack, points Substrate and kagent at it, and ends with one turn found in every backend. Nothing else works until this does.

Observe reads that telemetry: one turn's trace from the controller to the model call, the metrics agents and the controller produce, and the traffic through Substrate's two gateways.

Evaluate generates sessions to compare, scores them in agentevals, and finds the scores next to the traces they belong to.

Validate sends one session through the whole pipeline and maps each result to the step that set it.

This guide starts from an existing install. It adds observability to a cluster that already runs kagent on Agent Substrate. It does not install either.

Version support#

This guide is pinned to one set, and every version and chart below is part of that set:

ComponentVersion
kagent (kagent chart) and the kagent CLI1.0.1
Agent Substrate (substrate chart)1.0.1
OpenTelemetry Collector (opentelemetry-collector chart)chart 0.183.2, contrib image 0.165.0
Tempo (tempo chart)chart 1.24.4
Loki (loki chart)chart 7.7.0
Prometheus and Grafana (kube-prometheus-stack chart)chart 94.2.2
agentevals (agentevals chart)0.15.1

The kagent and Substrate versions are the ones already installed; Step 1 checks them, and Steps 6 and 7 upgrade those releases in place at the same version. A chart version fixes the image tags it deploys. No image in this guide is pinned by digest.

Environment setup#

Run this first, in every new shell you paste this guide's blocks into:

if [ -n "${ZSH_VERSION:-}" ]; then setopt interactive_comments nobanghist; fi
if [ -n "${BASH_VERSION:-}" ]; then set +H; fi
  • interactive_comments: an interactive zsh does not treat # as a comment unless this is set, so every comment line in a pasted block fails, and one containing < or > is a parse error.
  • nobanghist (zsh) and set +H (bash): an interactive shell expands ! inside double quotes as a history reference, which rewrites or rejects any line that contains one.

Then set these. Every command below uses them.

# Pinned versions. The platform this guide starts from; Step 1 checks it.
export KAGENT_VERSION=1.0.1
export SUBSTRATE_VERSION=1.0.1
# The observability stack, Steps 2 to 4.
export TEMPO_CHART_VERSION=1.24.4
export LOKI_CHART_VERSION=7.7.0
export KUBE_PROMETHEUS_STACK_CHART_VERSION=94.2.2
export OTEL_COLLECTOR_CHART_VERSION=0.183.2
# agentevals, Step 5.
export AGENTEVALS_VERSION=0.15.1
# The cluster. Every port-forward names this context, so a forward to another cluster is never touched.
export KUBE_CONTEXT=${KUBE_CONTEXT:-$(kubectl config current-context)}
# How far back the checks search Tempo, Loki and Prometheus, in seconds.
export LOOKBACK=${LOOKBACK:-3600}
# Local ports for the port-forwards.
export KAGENT_API_PORT=${KAGENT_API_PORT:-8083}
export KAGENT_UI_PORT=${KAGENT_UI_PORT:-8081}
export AGENTEVALS_PORT=${AGENTEVALS_PORT:-8001}
export GRAFANA_PORT=${GRAFANA_PORT:-3000}

What you need before you start#

RequirementNeeded forNotes
A cluster running kagent 1.0.1 on Agent Substrate 1.0.1EverythingWith the default install names: the kagent and substrate Helm releases in kagent and ate-system, the kagent Harness, the kagent-tool-server RemoteMCPServer and the default-model-config ModelConfig. Step 1 checks each
An OpenAI key in the default-model-config Secret, under OPENAI_API_KEYSteps 5, 8 and 13The agents already use it. Step 5 copies it for the evaluator's judge. It needs access to the agents' model and to gpt-4o
kubectl, helm, jq, curl, lsofEverything
The kagent CLI at 1.0.1Steps 8, 13 and 16Older CLIs have no kagent agent command. Check with kagent version
Permission to read Services through the API server (services/proxy) in telemetry and agentevalsThe checksThe checks query Tempo, Loki, Prometheus and agentevals through the API server, so they need no port-forward
Egress from the cluster to docker.io, quay.io, registry.k8s.io and ghcr.ioSteps 2 to 5Images
Access from your machine to grafana.github.io, prometheus-community.github.io, open-telemetry.github.io and ghcr.ioSteps 2 to 7Helm charts

Ports used in this guide#

PortWhat
8083kagent controller API, port-forwarded from Step 8. The kagent CLI talks to it. KAGENT_API_PORT moves it.
8081kagent UI, port-forwarded from Step 8. KAGENT_UI_PORT moves it.
3000Grafana, port-forwarded in Step 12. GRAFANA_PORT moves it.
8001agentevals UI, port-forwarded in Step 14. AGENTEVALS_PORT moves it.

Every port-forward binds 127.0.0.1 only. kubectl port-forward binds localhost by default; the --address 127.0.0.1 below makes it explicit so it is not changed by accident.

Port-forwards die. A port-forward is attached to one pod, and a rollout replaces the pod. The symptom is connection refused right after a step that appeared to work. Define these now and re-run forwards whenever something refuses to connect:

# forward <namespace> <target> <local port> <remote port>: open one port-forward to this cluster,
# replacing an older one to the same target.
forward() {
local pf tries=0
pkill -f "kubectl --context ${KUBE_CONTEXT} port-forward --address 127.0.0.1 -n $1 $2 " 2>/dev/null || true
while lsof -nP -iTCP:"$3" -sTCP:LISTEN >/dev/null 2>&1 && [ "$tries" -lt 5 ]; do sleep 1; tries=$((tries + 1)); done
if lsof -nP -iTCP:"$3" -sTCP:LISTEN >/dev/null 2>&1; then
echo "forward: port $3 is held by something else, often a forward to another cluster; set a free port in the environment block" >&2
return 1
fi
kubectl --context "${KUBE_CONTEXT}" port-forward --address 127.0.0.1 -n "$1" "$2" "$3:$4" >/dev/null 2>&1 &
pf=$!; tries=0
while kill -0 "$pf" 2>/dev/null && [ "$tries" -lt 20 ]; do
if curl -sS -o /dev/null --max-time 2 "http://127.0.0.1:$3/" 2>/dev/null; then
echo "forward up: $2 on 127.0.0.1:$3"; return 0
fi
sleep 1; tries=$((tries + 1))
done
echo "forward: $2 did not answer on 127.0.0.1:$3" >&2
return 1
}
# forwards: the kagent controller and UI.
forwards() {
kubectl --context "${KUBE_CONTEXT}" rollout status deployment/kagent-controller -n kagent --timeout=120s
forward kagent service/kagent-controller "${KAGENT_API_PORT}" 8083
forward kagent service/kagent-ui "${KAGENT_UI_PORT}" 8080
}
# stop_forwards: close every port-forward this guide opened to this cluster.
stop_forwards() {
if pkill -f "kubectl --context ${KUBE_CONTEXT} port-forward "; then
echo "closed the port-forwards to ${KUBE_CONTEXT}"
else
echo "no port-forwards open to ${KUBE_CONTEXT}"
fi
}

Every port-forward names this cluster's context, and forward closes only an older forward to the same target, so a forward you have open to another cluster is never touched. forward waits until the port answers, and reports a port that something else already holds rather than reading from it.

The checks in this guide do not use port-forwards. They read each backend through the API server with these helpers:

# svc_get <namespace> <service:port> <path and query>: GET from a Service through the API server.
svc_get() { kubectl get --raw "/api/v1/namespaces/$1/services/$2/proxy$3"; }
# urlenc <string>: percent-encode a query.
urlenc() { jq -rn --arg v "$1" '$v | @uri'; }
# prom <PromQL>: an instant query. One line per series: its labels, a tab, its value.
prom() {
svc_get telemetry kube-prometheus-stack-prometheus:9090 "/api/v1/query?query=$(urlenc "$1")" \
| jq -r '.data.result[] | "\(.metric | del(.__name__) | to_entries | map("\(.key)=\(.value)") | join(" "))\t\(.value[1])"'
}
# tempo <TraceQL> [limit]: the search response for traces from the last LOOKBACK seconds.
tempo() {
local now; now=$(date +%s)
svc_get telemetry tempo:3200 "/api/search?q=$(urlenc "$1")&limit=${2:-20}&start=$((now - LOOKBACK))&end=${now}"
}
# loki <LogQL> [limit]: the query response for log entries from the last LOOKBACK seconds.
loki() {
local now; now=$(date +%s)
svc_get telemetry loki:3100 "/loki/api/v1/query_range?query=$(urlenc "$1")&limit=${2:-20}&start=$((now - LOOKBACK))000000000&end=${now}000000000"
}
# trace_spans <trace id>: every span of a trace, oldest first: service, span name, duration.
# Leaves out the TaskStore span kagent writes for each streamed chunk.
trace_spans() {
svc_get telemetry tempo:3200 "/api/traces/$1" \
| jq -r '.batches[] | (.resource.attributes[] | select(.key == "service.name") | .value.stringValue) as $svc
| .scopeSpans[].spans[] | select(.name | test("TaskStoreService") | not)
| [(.startTimeUnixNano | tonumber), $svc, .name, ((((.endTimeUnixNano | tonumber) - (.startTimeUnixNano | tonumber)) / 1e6 | floor | tostring) + " ms")] | @tsv' \
| sort -n | cut -f2-
}
# kagent_cli <arguments>: the kagent CLI, pointed at this guide's port-forward to the controller.
kagent_cli() {
kagent --api-url "http://127.0.0.1:${KAGENT_API_PORT}" --gateway-url "http://127.0.0.1:${KAGENT_API_PORT}" "$@"
}

UP AND RUNNING#

Before you can read a trace or score a run, every component has to export to one place and that place has to store it.

If something breaks later, come back here and confirm this still works before changing anything else.

What you are going to do: check the platform you are starting from, install Tempo, Loki, Prometheus and Grafana, install the Collector that feeds them, install agentevals, point Substrate and kagent at the Collector, and find one agent turn in every backend.

What you will have that you did not have before: traces, metrics and logs from the kagent controller, every agent, and every Substrate component in one place, joined by trace ID.

Step 1: Check the platform you are starting from#

This guide upgrades the kagent and substrate Helm releases in place and uses resources the kagent install created. Confirm they are there, at the versions this guide pins:

helm list -n kagent -o json | jq -r '.[] | "\(.namespace)\t\(.chart)\t\(.status)"'
helm list -n ate-system -o json | jq -r '.[] | "\(.namespace)\t\(.chart)\t\(.status)"'
kubectl get workerpool,harness,modelconfig,remotemcpserver -n kagent
echo "model key Secret holds: $(kubectl get secret default-model-config -n kagent -o json | jq -r '.data | keys | join(", ")')"
echo "kagent CLI: $(kagent version | jq -r .kagent_version)"

You need kagent-1.0.1 and substrate-1.0.1, both deployed; a WorkerPool that is ready; the kagent Harness; the default-model-config ModelConfig; the kagent-tool-server RemoteMCPServer, accepted; OPENAI_API_KEY in the Secret; and a CLI at 1.0.1. The Secret line prints the names of its keys, never a value.

Step 2: Install Tempo and Loki#

Everything this guide installs for storage and display goes in one namespace:

kubectl get namespace telemetry >/dev/null 2>&1 || kubectl create namespace telemetry

Tempo stores traces. It receives OTLP from the Collector on 4317 and serves its query API on 3200:

helm upgrade --install tempo tempo \
--repo https://grafana.github.io/helm-charts \
--version ${TEMPO_CHART_VERSION} \
--namespace telemetry \
--wait \
-f - <<'EOF'
persistence:
enabled: false
tempo:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
EOF

Loki stores logs. This runs it as a single binary on a 2Gi volume, with every other deployment mode scaled to zero, and with structured metadata allowed: the Collector delivers each log record's attributes that way, and the queries in Observe filter on them.

helm upgrade --install loki loki \
--repo https://grafana.github.io/helm-charts \
--version ${LOKI_CHART_VERSION} \
--namespace telemetry \
--wait \
-f - <<'EOF'
backend:
replicas: 0
bloomCompactor:
replicas: 0
bloomGateway:
replicas: 0
chunksCache:
enabled: false
compactor:
replicas: 0
deploymentMode: SingleBinary
distributor:
replicas: 0
gateway:
enabled: false
indexGateway:
replicas: 0
ingester:
replicas: 0
limits_config:
allow_structured_metadata: true
loki:
auth_enabled: false
commonConfig:
replication_factor: 1
schemaConfig:
configs:
- from: "2024-04-01"
index:
period: 24h
prefix: loki_index_
object_store: filesystem
schema: v13
store: tsdb
storage:
type: filesystem
lokiCanary:
enabled: false
memberlist:
service:
publishNotReadyAddresses: true
minio:
enabled: false
monitoring:
selfMonitoring:
enabled: false
grafanaAgent:
installOperator: false
querier:
replicas: 0
queryFrontend:
replicas: 0
queryScheduler:
replicas: 0
read:
replicas: 0
resultsCache:
enabled: false
singleBinary:
persistence:
enabled: true
size: 2Gi
replicas: 1
test:
enabled: false
write:
replicas: 0
EOF

Check that both answer:

kubectl rollout status statefulset/tempo -n telemetry --timeout=300s
kubectl rollout status statefulset/loki -n telemetry --timeout=300s
echo "tempo: $(svc_get telemetry tempo:3200 /ready)"
echo "loki: $(svc_get telemetry loki:3100 /ready)"

Both lines end in ready. Tempo keeps traces on the pod's own disk (persistence.enabled: false), so they are gone when the pod restarts. Before production covers it.

Step 3: Install Prometheus and Grafana#

kube-prometheus-stack runs the Prometheus Operator, Prometheus and Grafana. Install it before any ServiceMonitor or PodMonitor, because it provides those CRDs.

helm upgrade --install kube-prometheus-stack kube-prometheus-stack \
--repo https://prometheus-community.github.io/helm-charts \
--version ${KUBE_PROMETHEUS_STACK_CHART_VERSION} \
--namespace telemetry \
--wait \
-f - <<'EOF'
alertmanager:
enabled: false
grafana:
additionalDataSources:
- name: Tempo
type: tempo
uid: tempo
# Tempo's HTTP API listens on 3200. Loki's is 3100.
url: http://tempo.telemetry.svc.cluster.local:3200
- name: Loki
type: loki
uid: loki
url: http://loki.telemetry.svc.cluster.local:3100
nodeExporter:
enabled: false
prometheus:
prometheusSpec:
podMonitorSelectorNilUsesHelmValues: false
serviceMonitorSelectorNilUsesHelmValues: false
EOF

The two SelectorNilUsesHelmValues: false settings make Prometheus pick up every ServiceMonitor and PodMonitor in the cluster, not only the ones this chart labels as its own. Steps 4, 6 and 7 each add one.

Warning

The Tempo data source uses port 3200. The Tempo Service has no port 3100; that is Loki's. With 3100 the data source is created without complaint and every trace query in Grafana fails.

Check the CRDs arrived and Prometheus answers:

kubectl get crd servicemonitors.monitoring.coreos.com podmonitors.monitoring.coreos.com -o name
echo "prometheus: $(svc_get telemetry kube-prometheus-stack-prometheus:9090 /-/ready)"

Step 4: Install the OpenTelemetry Collector#

The Collector is the one address every component exports to: OTLP over gRPC on 4317 and over HTTP on 4318. It runs five pipelines:

PipelineFromToWhat it changes
tracesOTLPTempo, and the signal_to_metrics connectorDeletes the GenAI request and usage attributes from some runtime spans (Attachment A.3)
metricsOTLP, and the connectorA Prometheus endpoint on 8889Converts delta metrics to cumulative
logsOTLPLokiNothing
traces/agentevalsOTLPagentevalsKeeps agent runtime spans only, and drops TaskStore spans
logs/agentevalsOTLPagentevalsKeeps agent runtime logs only

The connector turns every invoke_agent span into a sample of a histogram, gen_ai.invoke_agent.duration, so a turn's duration is a metric as well as a span. Attachment A explains each processor.

The heredoc is quoted (<<'EOF'), so the shell passes the configuration through untouched:

helm upgrade --install otel-collector opentelemetry-collector \
--repo https://open-telemetry.github.io/opentelemetry-helm-charts \
--version ${OTEL_COLLECTOR_CHART_VERSION} \
--namespace telemetry \
--wait \
-f - <<'EOF'
config:
connectors:
signal_to_metrics:
spans:
- attributes:
- key: gen_ai.agent.name
optional: true
- key: gen_ai.request.model
optional: true
- key: error.type
optional: true
conditions:
- span.attributes["gen_ai.operation.name"] == "invoke_agent" and instrumentation_scope.name
!= "github.com/kagent-dev/kagent/go/adk/pkg/a2a/server" and instrumentation_scope.name
!= "kagent.core.a2a"
description: The duration of one agent invocation, derived from its span.
histogram:
buckets:
- 0.5
- 1
- 2
- 5
- 10
- 30
- 60
- 120
- 300
value: Seconds(span.end_time - span.start_time)
include_resource_attributes:
- key: service.name
- key: service.namespace
optional: true
- key: service.version
optional: true
- key: kagent.runtime
optional: true
- key: gen_ai.main_agent.id
optional: true
name: gen_ai.invoke_agent.duration
unit: s
exporters:
otlp_grpc/tempo:
endpoint: tempo.telemetry.svc.cluster.local:4317
tls:
insecure: true
otlp_http/loki:
endpoint: http://loki.telemetry.svc.cluster.local:3100/otlp
otlp_http/agentevals:
endpoint: http://agentevals.agentevals.svc.cluster.local:4318
prometheus:
endpoint: 0.0.0.0:8889
# The default (5m) drops a series five minutes after its last update, so each
# burst of agent turns starts a new series and rate()/increase() miss turns.
metric_expiration: 60m
resource_to_telemetry_conversion:
enabled: true
processors:
batch: {}
delta_to_cumulative: {}
# agentevals groups spans into sessions by gen_ai.conversation.id and falls back
# to the trace ID. Forward only agent runtime telemetry, so Substrate,
# agentgateway and controller background traces don't show up as sessions.
filter/agent_runtimes_only:
error_mode: ignore
traces:
span:
- resource.attributes["kagent.runtime"] == nil
logs:
log_record:
- resource.attributes["kagent.runtime"] == nil
# kagent writes a TaskStore RPC span per streamed chunk. agentevals keeps only
# the first 10,000 spans of a trace, so a long turn could lose its invoke_agent span.
filter/kagent_taskstore:
error_mode: ignore
traces:
span:
- IsMatch(span.attributes["rpc.method"], "^kagent\\.runtime\\.v1\\.TaskStoreService/")
- IsMatch(span.name, "^kagent\\.runtime\\.v1\\.TaskStoreService/")
transform/harness_native_genai:
error_mode: ignore
trace_statements:
- conditions:
- resource.attributes["kagent.genai.producer"] == "runtime" and not span.attributes["llm_request.context"]
== "standalone"
context: span
statements:
- delete_matching_keys(span.attributes, "^gen_ai\\.(operation\\.name|system|request\\.model|response\\.finish_reasons|usage\\..*)$")
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
service:
pipelines:
logs:
exporters:
- otlp_http/loki
processors:
- batch
receivers:
- otlp
metrics:
exporters:
- prometheus
processors:
- delta_to_cumulative
- batch
receivers:
- otlp
- signal_to_metrics
traces:
exporters:
- signal_to_metrics
- otlp_grpc/tempo
processors:
- transform/harness_native_genai
- batch
receivers:
- otlp
# Agent turns for agentevals to score. agentevals sends its scores back
# as logs, which the logs pipeline above delivers to Loki.
traces/agentevals:
exporters:
- otlp_http/agentevals
processors:
- filter/agent_runtimes_only
- filter/kagent_taskstore
- batch
receivers:
- otlp
logs/agentevals:
exporters:
- otlp_http/agentevals
processors:
- filter/agent_runtimes_only
- batch
receivers:
- otlp
fullnameOverride: otel-collector
image:
repository: otel/opentelemetry-collector-contrib
mode: deployment
ports:
metrics-export:
containerPort: 8889
enabled: true
protocol: TCP
servicePort: 8889
EOF
Warning

The regular expressions need doubled backslashes (\\.). With a single backslash the Collector fails to parse its configuration and crash-loops, and nothing reaches any backend. An unquoted heredoc (<<EOF) halves them on the way in, which is why this one is quoted. If you move these values to a file, keep them doubled.

Let Prometheus scrape the metrics the Collector serves on 8889, the port named metrics-export above:

kubectl apply -f- <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: otel-collector
namespace: telemetry
spec:
endpoints:
- interval: 15s
port: metrics-export
selector:
matchLabels:
app.kubernetes.io/instance: otel-collector
EOF

Check the Collector started and Prometheus has found it. A new target takes up to a minute to appear, so the block waits for it:

kubectl rollout status deployment/otel-collector -n telemetry --timeout=300s
for i in $(seq 1 24); do
[ -n "$(prom 'up{job="otel-collector"} == 1')" ] && break
sleep 5
done
prom 'up{job="otel-collector"}'

One line ending in 1. A Collector that restarts in a loop here is the backslash warning above; kubectl logs deployment/otel-collector -n telemetry --previous names the line it could not parse.

Note

The Collector logs export errors for otlp_http/agentevals until Step 5. Its two agentevals pipelines send to a Service that does not exist yet. The other three pipelines are unaffected.

Step 5: Install agentevals#

agentevals receives agent turns from the Collector, groups them into sessions, and scores one session against another. Its values turn on evaluation events and send them to the Collector over OTLP HTTP, so each score lands in Loki as a gen_ai.evaluation.result event that carries the trace and span ID of the turn it scored.

The LLM-backed metrics (final_response_match_v2, hallucinations_v1 and the rubric_based_* metrics) need a key for the judge model. agentevals reads OPENAI_API_KEY, ANTHROPIC_API_KEY or GOOGLE_API_KEY from its environment, here from a Secret named agentevals-judge. This copies the OpenAI key the agents already use, from one Secret to the other over stdin, without printing it. Create the Secret before installing, or the pod does not start:

kubectl get namespace agentevals >/dev/null 2>&1 || kubectl create namespace agentevals
kubectl delete secret agentevals-judge -n agentevals --ignore-not-found
kubectl get secret default-model-config -n kagent -o jsonpath='{.data.OPENAI_API_KEY}' | base64 --decode \
| kubectl create secret generic agentevals-judge -n agentevals --from-file=OPENAI_API_KEY=/dev/stdin
echo "judge key: $(kubectl get secret agentevals-judge -n agentevals -o jsonpath='{.data.OPENAI_API_KEY}' | base64 --decode | wc -c | tr -d ' ') bytes"

The last line prints the key's length. 0 bytes means default-model-config has no OPENAI_API_KEY: the Secret was still created, empty, and the judge will fail when a metric needs it.

helm upgrade --install agentevals oci://ghcr.io/agentevals-dev/agentevals/helm/agentevals \
--version ${AGENTEVALS_VERSION} \
--namespace agentevals \
--wait \
-f - <<'EOF'
# Send evaluation results to the Collector as gen_ai.evaluation.result log events,
# so scores land in Loki next to the agent traces in Tempo.
env:
- name: AGENTEVALS_EVALUATION_EVENTS
value: "true"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector.telemetry.svc.cluster.local:4318
- name: OTEL_SERVICE_NAME
value: agentevals
# Key for the LLM judge (OPENAI_API_KEY), used by the LLM-backed metrics such as
# final_response_match_v2.
envFrom:
- secretRef:
name: agentevals-judge
EOF

Check it is up and has found the judge's key:

kubectl rollout status deployment/agentevals -n agentevals --timeout=300s
svc_get agentevals agentevals:8001 /api/config | jq -c '.data'

"openai":true under apiKeys, and the OTLP ports the Collector sends to. The Collector's export errors from Step 4 stop here.

The Collector forwards only telemetry from agent runtimes, the resources that carry a kagent.runtime attribute. agentevals turns any trace without a conversation ID into a session of its own, so Substrate, gateway and controller traces would otherwise fill its session list.

Step 6: Point Substrate at the Collector#

One otel.endpoint sends ate-api-server, ate-controller, atelet, the workers and both gateways to the Collector. samplingRatio: "1.0" keeps every trace instead of one in a hundred.

The upgrade also enables the GoldenEgressPolicy preview gate. kagent 1.0.0-rc3 and later set a golden egress policy on every ActorTemplate. Without the gate, Substrate rejects them and Agents show Ready=False with reason ActorTemplateRejected.

--reuse-values keeps everything your install set, so the block carries only what it adds:

helm upgrade substrate oci://ghcr.io/kagent-dev/substrate/helm/substrate \
--version ${SUBSTRATE_VERSION} \
--namespace ate-system \
--reuse-values \
--wait --timeout 10m \
-f - <<'EOF'
otel:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
traces:
samplingRatio: "1.0"
# kagent rc3 and later set goldenEgressPolicy on every ActorTemplate it compiles.
# Without the GoldenEgressPolicy gate, Substrate rejects those templates and
# Agents report ActorTemplateRejected (InvalidArgument).
preview:
- PerTemplateSnapshotLocation
- GoldenEgressPolicy
EOF
Warning

preview is a list, and Helm replaces a list whole. If your release already enables a preview gate that is not in the block, it is turned off. Check with helm get values substrate -n ate-system first, and add any gate you find to the list.

Substrate runs two agentgateway instances in ate-system, and both serve Prometheus metrics on :15020/metrics:

  • atenet-router is the ingress. It routes traffic from the kagent controller to actors and wakes suspended actors. Its metrics port is named gw-metrics.
  • atenet-egress is the egress. It intercepts every outbound call an actor makes, such as model APIs and MCP servers. Its metrics port is named stats.

The router carries a prometheus.io/scrape annotation, which kube-prometheus-stack ignores, so a PodMonitor is required. Each pod has only one of the two port names, so each pod is scraped once. No network change is needed: Substrate's ate-system-observability NetworkPolicy already allows ingress on both port names.

kubectl apply -f- <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: agentgateway
namespace: telemetry
spec:
namespaceSelector:
matchNames:
- ate-system
selector:
matchExpressions:
- key: app
operator: In
values:
- atenet-router
- atenet-egress
podMetricsEndpoints:
# Each pod only exposes one of these port names, so each pod is scraped once.
- port: gw-metrics
path: /metrics
interval: 15s
- port: stats
path: /metrics
interval: 15s
EOF

Check the release holds the telemetry settings, and that Prometheus has found both gateways:

helm get values substrate -n ate-system -o json | jq -c '{otel, preview}'
for i in $(seq 1 24); do
[ "$(prom 'count(up{job="telemetry/agentgateway"} == 1)' | cut -f2)" = 2 ] && break
sleep 5
done
prom 'up{job="telemetry/agentgateway"}'

Two lines ending in 1, one for an atenet-router pod and one for an atenet-egress pod.

Step 7: Point kagent at the Collector#

config.telemetry covers the kagent controller, and config.runtimeDefaults.telemetry covers the agents. captureContent puts prompts, responses and tool arguments on spans. agentevals needs that to score responses.

controller.metrics exposes the controller's own Prometheus endpoint and creates a ServiceMonitor for it. The endpoint is served securely, so the scrape is authorized only once the controller's metrics-reader role is bound to the ServiceAccount Prometheus runs as; naming that ServiceAccount makes the chart render the binding. Step 10 reads a metric that comes only from this endpoint.

--reuse-values keeps everything the install set:

helm upgrade kagent oci://ghcr.io/kagent-dev/kagent/helm/kagent \
--version ${KAGENT_VERSION} \
--namespace kagent \
--reuse-values \
--wait \
-f - <<'EOF'
config:
telemetry:
traces:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
metrics:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
logs:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
runtimeDefaults:
telemetry:
captureContent: true
traces:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
metrics:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
logs:
endpoint: http://otel-collector.telemetry.svc.cluster.local:4317
controller:
metrics:
enabled: true
serviceMonitor:
enabled: true
prometheusServiceAccount:
name: kube-prometheus-stack-prometheus
namespace: telemetry
EOF
Warning

With captureContent on, every prompt, response and tool argument is stored in Tempo and sent to agentevals. Anyone who can query either can read them. Do not put sensitive data through agents on this cluster.

If you changed the model API key in the kagent UI, this upgrade can conflict with the chart's default-model-config. Attachment C.6 has the fix.

Check the controller's configuration and its scrape target:

kubectl rollout status deployment/kagent-controller -n kagent --timeout=300s
kubectl get configmap kagent-controller -n kagent -o jsonpath='{.data.controller\.yaml}' | grep -c 'otel-collector.telemetry.svc.cluster.local:4317'
for i in $(seq 1 24); do
[ -n "$(prom 'up{job="kagent-controller-metrics"} == 1')" ] && break
sleep 5
done
prom 'up{job="kagent-controller-metrics"}'

6 endpoints in the controller's configuration, three for the controller and three for the agent runtimes, and one scrape target ending in 1.

Step 8: Verify the first turn in every backend#

The checks talk to one agent, smoke-agent: the default model, read-only Kubernetes tools from kagent-tool-server, and the kagent Harness. An Agent of that name that already exists is updated to this definition:

kubectl apply -f- <<'EOF'
apiVersion: api.kagent.dev/v1alpha3
kind: Agent
metadata:
name: smoke-agent
namespace: kagent
spec:
harnessRef:
name: kagent
template:
inline:
description: Smoke-test agent for verifying the kagent + Substrate install
modelConfig:
name: default-model-config
systemPrompt: You are a concise assistant. Answer in one sentence.
tools:
- mcp:
server:
kind: RemoteMCPServer
name: kagent-tool-server
tools:
- k8s_get_resources
- k8s_describe_resource
- k8s_get_events
- k8s_get_pod_logs
EOF
kubectl wait agent/smoke-agent -n kagent --for=condition=Ready --timeout=300s

kagent bakes telemetry settings into each agent revision. An agent that existed before Step 7 keeps running its old revision until the new one is ready, and a chat that was already open stays on the revision it started with. Wait until each Agent's desired and latest revisions match, and use a new session after that:

for i in $(seq 1 60); do
[ "$(kubectl get agent smoke-agent -n kagent -o jsonpath='{.status.desiredRevision}')" = "$(kubectl get agent smoke-agent -n kagent -o jsonpath='{.status.latestSuccessfulRevision}')" ] && break
sleep 5
done
kubectl get agents -n kagent \
-o custom-columns='NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,DESIRED:.status.desiredRevision,LATEST:.status.latestSuccessfulRevision'

READY is True, and DESIRED equals LATEST on every line.

Bring the forwards up, so the kagent CLI can reach the controller:

forwards

Create a session and send one message that needs a tool. The CLI acts as admin@kagent.dev in the kagent namespace by default:

export FIRST_SESSION=$(kagent_cli agent session create --agent smoke-agent -o json | jq -r .session.id)
: "${FIRST_SESSION:?is empty: the controller returned no session. Run forwards and try again.}" && {
echo "session: ${FIRST_SESSION}"
kagent_cli agent invoke --session "$FIRST_SESSION" \
-t "Use your tools to list the namespaces in this cluster, then tell me how many pods are running in the kagent namespace. Answer in two short sentences."
}

An answer alone does not prove the telemetry arrived. The session's ID is on every span the agent writes, as gen_ai.conversation.id, and Substrate names the session's actor after it, so look for that ID in each backend. The Collector batches for a few seconds, so the block waits for the trace first:

: "${FIRST_SESSION:?is empty: run step-8-first-turn in this shell first}" && {
TURN_QUERY="{resource.service.name=\"smoke-agent\" && name=~\"invoke_agent.*\" && span.gen_ai.conversation.id=\"${FIRST_SESSION}\"}"
for i in $(seq 1 24); do
[ -n "$(tempo "$TURN_QUERY" | jq -r '.traces[0].traceID // empty')" ] && break
sleep 5
done
echo "-- Tempo: the turn's trace"
tempo "$TURN_QUERY" | jq -r '.traces[] | "\(.traceID)\t\(.rootServiceName)\t\(.rootTraceName)\t\(.durationMs) ms"'
echo "-- Prometheus: turns counted from invoke_agent spans"
prom "sum by (service_name, gen_ai_agent_name) (last_over_time(gen_ai_invoke_agent_duration_seconds_count[${LOOKBACK}s]))"
echo "-- Loki: the ingress gateway's access log for this session's actor"
loki "{service_name=\"agentgateway\"} | ate_actor_name=\"session-${FIRST_SESSION}\"" \
| jq -r '.data.result[].stream | "\(.route)\t\(.http_response_status_code)\t\(.duration)\tresume=\(.ate_router_resume)\ttrace=\(.trace_id)"'
echo "-- agentevals: the session"
svc_get agentevals agentevals:8001 /api/streaming/sessions \
| jq -c --arg s "$FIRST_SESSION" '.data[] | select(.sessionId == $s) | {sessionId, spanCount, isComplete}'
}
LineWhat it shows
TempoOne trace whose root is the kagent controller's A2A request. The agent's invoke_agent span is inside it
PrometheusA count for smoke-agent: the Collector's connector made a metric sample from the span
LokiThe request the controller sent through atenet-router, with status 200, whether it had to resume the actor, and the same trace ID as the Tempo line
agentevalsThe session, with its span count. isComplete turns true a few seconds after the last answer

What you now have: every component exporting to one Collector, three backends holding what it sends, and one turn found in all of them by its session ID. What you have not done yet is read any of it. Observe does that.

OBSERVE#

Up and Running proved the telemetry arrives. This section reads it, so that when a turn is slow or wrong you know which backend answers which question.

What you are going to do: follow one turn's trace from the controller to the model call, read the metrics agents and the controller produce, look at the traffic through Substrate's two gateways, and open the same data in Grafana.

What you will have that you did not have before: the queries that find a turn, a metric or a gateway request, and a picture of which component sends which signal.

ComponentSends
kagent controllerTraces, metrics, logs
Agents (kagent runtimes such as smoke-agent)Traces (invoke_agent, one span per model call, execute_tool), metrics, logs
Substrate (ate-api-server, ate-controller, atelet, workers)Traces, metrics, logs
agentgateway router and egressTraces, access logs, and metrics scraped directly
agentevalsLogs (the gen_ai.evaluation.result score events)

Step 9: Read a turn's trace#

Find the first session's trace and list its spans, oldest first:

: "${FIRST_SESSION:?is empty: run step-8-first-turn in this shell first}" && {
export FIRST_TRACE=$(tempo "{resource.service.name=\"smoke-agent\" && name=~\"invoke_agent.*\" && span.gen_ai.conversation.id=\"${FIRST_SESSION}\"}" \
| jq -r '.traces | sort_by(.startTimeUnixNano | tonumber) | last | .traceID')
echo "trace: ${FIRST_TRACE}"
trace_spans "$FIRST_TRACE" | grep -v $'\t0 ms$'
}

The grep leaves out spans shorter than a millisecond, which are mostly Substrate's authorization and database calls. A turn reads top to bottom:

ServiceSpansWhat happened
kagent-controllerThe A2A requestThe message entered through the controller
agentgatewayThe same request, and ResumeActorThe ingress gateway routed it to the session's actor, and woke the actor first if it was suspended
ateapi, atelet, the workerResumeActor, Restore, RestoreWorkloadSubstrate placed the actor on a worker and restored it from its snapshot
The agent (smoke-agent)invoke_agentThe agent's turn
The agentOne span per model callThe model and its token counts
The agentexecute_toolEach tool call to kagent-tool-server

The Substrate rows appear only when the actor had to be resumed, which is every turn that starts from a suspended session.

Step 10: Agent and controller metrics#

Metrics reach Prometheus two ways. Everything that exports OTLP goes through the Collector, which serves it on port 8889 with each resource's attributes as labels, service_name among them. The kagent controller and the two gateways are also scraped directly.

See which services send metrics through the Collector:

prom 'count by (service_name) ({job="otel-collector"})'

The turn-duration histogram the Collector derives from invoke_agent spans:

prom "sum by (service_name, kagent_runtime) (last_over_time(gen_ai_invoke_agent_duration_seconds_count[${LOOKBACK}s]))"
prom "sum by (service_name) (last_over_time(gen_ai_invoke_agent_duration_seconds_sum[${LOOKBACK}s]))"

The first line counts turns per agent and the second sums their seconds, so the second divided by the first is the mean turn. last_over_time is there because an idle agent's series leaves the Collector's endpoint an hour after its last turn (metric_expiration: 60m), and an instant query looks back only five minutes.

And a metric that comes only from the controller's own endpoint, through the ServiceMonitor Step 7 created:

prom 'count by (job) (kagent_runtime_revision_gc_duration_seconds_bucket)'

One line, for the job kagent-controller-metrics.

Step 11: Substrate's gateways#

Every message to an agent enters through atenet-router, and every call an agent makes leaves through atenet-egress. The PodMonitor from Step 6 scrapes both:

prom 'sum by (pod, route, status) (agentgateway_requests_total)'

One line for each gateway pod, route and status. The metrics worth knowing:

MetricWhat it measures
agentgateway_requests_totalRequests, by route and status
agentgateway_request_duration_secondsThe whole request
agentgateway_upstream_call_duration_secondsThe gateway's own call to the destination
agentgateway_atenet_router_route_duration_secondsRouter only: the time to route a request to an actor, including waking it

The gateways' access logs go through the Collector to Loki, one record per request, with the request's fields as structured metadata:

loki '{service_name="agentgateway"}' 10 \
| jq -r '.data.result[].stream | "\(.route)\t\(.http_response_status_code)\t\(.duration)\tactor=\(.ate_actor_name // "-")\ttrace=\(.trace_id)"'

Each line carries the trace ID of the turn it belongs to, which is how a gateway log line leads back to an agent's trace in Step 9.

Step 12: Open Grafana#

The same data is in Grafana, which has Prometheus, Tempo and Loki as data sources from Step 3. Forward it:

forward telemetry service/kube-prometheus-stack-grafana "${GRAFANA_PORT}" 80

Open http://localhost:3000 (or your GRAFANA_PORT). The login is admin, and the password is in the chart's Secret. To copy it without displaying it, on macOS:

kubectl get secret kube-prometheus-stack-grafana -n telemetry -o jsonpath='{.data.admin-password}' | base64 --decode | pbcopy

Agent traces.

  1. Go to Explore.
  2. Choose the Tempo data source.
  3. Switch the query type to TraceQL.
  4. Run this to find the agent turns, and open a trace:
{resource.service.name="smoke-agent" && name=~"invoke_agent.*"}

Metrics.

  1. Choose the Prometheus data source.
  2. Look up kagent_runtime_revision_gc_duration_seconds_bucket, or any metric from Steps 10 and 11.

Gateway logs.

  1. Choose the Loki data source.
  2. Switch the query editor, on the right side, from Builder to Code.
  3. Run:
{service_name="agentgateway"}

The browser half is not part of the scripted run.

What you now have: a turn followed from the controller through Substrate to the model and its tools, the metrics behind it, and the gateways' own record of the traffic, each joined to the others by trace ID. None of it says whether the agent's answer was any good. Evaluate does that.

EVALUATE#

Observe showed what an agent did. This section scores it: agentevals takes one session as the reference, the golden run, and measures other sessions against it.

What you are going to do: generate sessions that can be compared, score them in agentevals, and find the scores in Loki beside the traces they belong to.

What you will have that you did not have before: a measure of how much one agent varies from run to run, stored with the telemetry of the turns it measured.

Step 13: Generate sessions to compare#

Each run below creates a new session and sends it the same two messages. Every session shows up in agentevals as one conversation with two turns: the Collector forwards every span from a kagent agent runtime, and agentevals groups them by gen_ai.conversation.id, which is the kagent session ID.

forwards
AGENTS=(smoke-agent)
RUNS=2
for agent in "${AGENTS[@]}"; do
for run in $(seq 1 "$RUNS"); do
session=$(kagent_cli agent session create --agent "$agent" -o json | jq -r .session.id)
echo "== $agent run $run ($session)"
kagent_cli agent invoke --session "$session" \
-t "Use your tools to list the namespaces in this cluster, then tell me how many pods are running in the kagent namespace. Answer in two short sentences."
kagent_cli agent invoke --session "$session" \
-t "Now use your tools to list the services in the agentevals namespace. One sentence."
done
done

Add -S to kagent agent invoke to stream the answers.

Check that agentevals received the sessions. Each one is marked complete a few seconds after its last answer:

svc_get agentevals agentevals:8001 /api/streaming/sessions \
| jq -c '.data[] | {sessionId, spanCount, isComplete}'

From the UI instead. The kagent UI creates sessions through the same controller API as the CLI, so each UI chat shows up in agentevals as one session, the same way.

  1. Open http://localhost:8081 (or your KAGENT_UI_PORT) and select smoke-agent.
  2. Start a New chat. The UI also calls it New conversation in a few places. Both create a new session.
  3. Send both prompts in that one chat. One chat with two messages is one agentevals session with two turns.
  4. For a second session to compare, start another New chat and send the same two prompts again.

Step 14: Score the sessions#

Forward the agentevals UI:

forward agentevals service/agentevals "${AGENTEVALS_PORT}" 8001
  1. Open http://localhost:8001 (or your AGENTEVALS_PORT).
  2. Click Local Development. Each session is one card with two turns.
  3. On a smoke-agent session card, click Set as EvalSet. That session is now the golden run.
  4. Click Continue to Evaluation.
  5. Under Evaluation Settings, set Judge Model to openai/gpt-4o.
  6. Select the metrics and click Run Evaluation:
MetricWhat it checks
tool_trajectory_avg_scoreThat each turn called the same tools with the same arguments. Set the match type to ANY_ORDER if the order does not matter
response_match_scoreEach answer against the golden one, by ROUGE-1 text overlap
final_response_match_v2Whether the judge model finds each answer means the same as the golden one, so different wording of the same answer still passes. It needs the judge key from Step 5
  1. Click another smoke-agent session in the results to compare its expected and actual tool calls turn by turn. It shows how much the same agent varies from run to run.

Attachment B runs the same comparison across two agents on different models.

Step 15: Find the scores beside the traces#

agentevals sends every score to the Collector as a gen_ai.evaluation.result log event, and the Collector's logs pipeline delivers it to Loki. Each event carries the metric, the score, the session, and the trace and span ID of the turn it scored:

loki '{service_name="agentevals"} | gen_ai_evaluation_name != ""' 50 \
| jq -r '.data.result[].stream | "\(.gen_ai_evaluation_name)\t\(.gen_ai_evaluation_score_value)\t\(.gen_ai_evaluation_score_label // "-")\tsession=\(.gen_ai_conversation_id)\ttrace=\(.trace_id)"'

One line per metric and turn scored. Before you run an evaluation in Step 14 this prints nothing. Pass a line's trace ID to trace_spans from Step 9, or paste it into Grafana's Tempo data source, to open the turn that score belongs to.

What you now have: sessions scored against a golden run, and every score stored with the telemetry of the turn it measured.

VALIDATE#

Everything above was checked one piece at a time. This section sends one new session through the whole pipeline and checks each result against the step that set it up. If something breaks later, this is the section to run first.

What you are going to do: check the three scrape targets, run one session that calls the model and a tool, then look for that session in Tempo, Prometheus, Loki and agentevals.

What you will have that you did not have before: one pass that tells you whether the pipeline still does what each step said it would, and which step to go back to when it does not.

Step 16: Drive one session through every signal#

record prints one check: the step that set it up, what was checked, what was observed, and whether that matches what the step said. It also keeps the line for Step 17:

# record <step> <what was checked> <observed> <expected: an extended regular expression>
record() {
local result=FAIL
printf '%s' "$3" | grep -qE -- "$4" && result=PASS
VALIDATE_RESULTS="${VALIDATE_RESULTS:-}${result}|$1|$2|$3"$'\n'
printf '%-4s %-12s %s: %s\n' "$result" "$1" "$2" "$3"
}

What Prometheus scrapes. The Collector, both gateways and the controller:

VALIDATE_RESULTS=""
record "Step 4" "Collector scrape targets up" "$(prom 'count(up{job="otel-collector"} == 1)' | cut -f2)" '^[1-9]'
record "Step 6" "Gateway scrape targets up" "$(prom 'count(up{job="telemetry/agentgateway"} == 1)' | cut -f2)" '^2$'
record "Step 7" "Controller scrape targets up" "$(prom 'count(up{job="kagent-controller-metrics"} == 1)' | cut -f2)" '^[1-9]'

The session. One turn that needs both the model and a tool, then a wait for its trace:

forwards >/dev/null
export VALIDATE_SESSION=$(kagent_cli agent session create --agent smoke-agent -o json | jq -r .session.id)
kagent_cli agent invoke --session "$VALIDATE_SESSION" \
-t "Use your tools to count the pods in the kagent namespace. One sentence." >/dev/null
VALIDATE_QUERY="{resource.service.name=\"smoke-agent\" && name=~\"invoke_agent.*\" && span.gen_ai.conversation.id=\"${VALIDATE_SESSION}\"}"
for i in $(seq 1 24); do
VALIDATE_TRACE=$(tempo "$VALIDATE_QUERY" | jq -r '.traces[0].traceID // empty')
[ -n "$VALIDATE_TRACE" ] && break
sleep 5
done
record "Steps 7, 8" "The turn's trace in Tempo" "$([ -n "$VALIDATE_TRACE" ] && echo found || echo none)" '^found$'

The trace. What the agent did, and that Substrate's part of the turn is in the same trace:

record "Step 9" "Agent spans in the trace" "$(trace_spans "$VALIDATE_TRACE" \
| awk -F'\t' '{split($2, w, " "); n[w[1]]++} END {printf "invoke_agent=%d generate_content=%d execute_tool=%d", n["invoke_agent"], n["generate_content"], n["execute_tool"]}')" \
'^invoke_agent=1 generate_content=[1-9][0-9]* execute_tool=[1-9]'
record "Step 6" "Services in the trace" "$(trace_spans "$VALIDATE_TRACE" | cut -f1 | sort -u | tr '\n' ' ')" 'agentgateway.*kagent-controller.*smoke-agent'

The other backends. The gateway's log, the derived metric, and the evaluator:

record "Steps 6, 11" "Ingress access log for the session's actor" "status $(loki "{service_name=\"agentgateway\"} | ate_actor_name=\"session-${VALIDATE_SESSION}\"" \
| jq -r '[.data.result[].stream.http_response_status_code] | unique | join(",")')" '^status 200$'
record "Steps 4, 10" "Turns counted from invoke_agent spans" "$(prom "sum(last_over_time(gen_ai_invoke_agent_duration_seconds_count{service_name=\"smoke-agent\"}[${LOOKBACK}s]))" | cut -f2)" '^[1-9]'
record "Step 5" "The session in agentevals" "$(svc_get agentevals agentevals:8001 /api/streaming/sessions \
| jq -r --arg s "$VALIDATE_SESSION" '[.data[] | select(.sessionId == $s)] | length') found" '^1 found$'

Step 17: Map each result to the step that set it#

printf '%s' "$VALIDATE_RESULTS" | awk -F'|' 'NF >= 3 {printf "%-4s set in %-12s %s\n", $1, $2, $3}'
FAILED=$(printf '%s' "$VALIDATE_RESULTS" | grep -c '^FAIL' || true)
echo "checks: $(printf '%s' "$VALIDATE_RESULTS" | grep -c '|' || true), failed: ${FAILED}"

Every check names the step that set it up, so a FAIL sends you back to one place. Read them in the order a turn passes through the pipeline:

OrderWhat happensSet inChecked by
1The controller receives the message and exports its span to the CollectorStep 7The turn's trace in Tempo
2The ingress gateway routes the message to the session's actor, and logs the requestStep 6Services in the trace, ingress access log
3The agent runs the turn and exports its spans, with the session's ID on eachSteps 7, 8Agent spans in the trace
4The Collector sends every span to Tempo and makes a metric sample from the invoke_agent spanStep 4Turns counted from spans
5Prometheus scrapes the Collector, the gateways and the controllerSteps 4, 6, 7The three scrape targets
6The Collector forwards the agent's spans, and only those, to agentevalsSteps 4, 5The session in agentevals

What you built#

  • One Collector receives traces, metrics and logs from the kagent controller, every agent, and every Substrate component, and sends each signal to the backend that stores it.
  • Tempo holds a turn as one trace, from the controller's A2A request through Substrate's gateways and actor restore to the agent's model and tool calls.
  • Prometheus holds the metrics the Collector receives, a turn-duration histogram derived from spans, and the gateways' and controller's own metrics, scraped directly.
  • Loki holds the gateways' access logs and the agents' logs, each with the trace ID of its turn.
  • agentevals receives agent turns only, scores one session against another, and writes every score back to Loki with the trace and span ID of the turn it scored.
  • Grafana reads all three.

What it does not do yet is in Before production.

Before production#

Each item is a limit of this setup that you can plan for, with the step that shows it.

  • Turn content capture off unless you need it. captureContent: true stores every prompt, response and tool argument on spans, in Tempo and in agentevals. agentevals needs it to score responses; nothing else in this guide does (Step 7).
  • Give Tempo storage. It runs with persistence.enabled: false, so every trace is lost when its pod restarts (Step 2).
  • Size Loki, or move it off a single binary. It is one pod with a 2Gi filesystem volume, a replication factor of 1, and authentication off (Step 2).
  • Lower Substrate's trace sampling. samplingRatio: "1.0" keeps every trace, which suits a demo. The chart's default is 0.01 (Step 6).
  • Restrict who can send to the Collector. Its OTLP receivers listen on every address with no authentication, and this guide puts no NetworkPolicy in telemetry (Step 4).
  • Turn alerting back on. This guide disables Alertmanager and the node exporter (Step 3).
  • Give Grafana real sign-in. It has one admin user whose password is in a Secret (Step 12).
  • Give the judge its own key. The evaluator reuses the agents' OpenAI key, so judge spend and agent spend are one bill, and anyone who can read Secrets in agentevals holds the agents' key (Step 5).
  • Keep agentevals at one replica. It holds live sessions in the memory of the pod that receives them, so with more replicas one session's telemetry is split across pods, and a restart loses the sessions it held (Step 5).
  • Expect long turns to be truncated in agentevals. It keeps only the first 10,000 spans of a trace. The Collector drops kagent's per-chunk TaskStore spans for that reason (Step 4).
  • Expect idle agents to disappear from instant queries. The Collector stops serving a series an hour after its last update, so dashboards over agent metrics need a range (Step 10).
  • Pin images by digest. Each chart version here fixes image tags, not digests (Version support).

When you are done with this cluster, or before working on another, close its port-forwards:

stop_forwards
Attachments

Attachments to the Build Guide for Observing and Evaluating Agent Workloads on Kubernetes. Each assumes the guide's Environment setup block and its two helper blocks have been run in your shell.

Attachment A: The Collector's configuration#

Step 4 installs the Collector with one long values block. This attachment says what each part of it does, so you can change it without breaking a pipeline.

A.1 What comes in and where it goes#

One OTLP receiver, on gRPC 4317 and HTTP 4318, takes everything. Four exporters send it on:

ExporterDestinationCarries
otlp_grpc/tempoTempo, port 4317, without TLSEvery trace
otlp_http/lokiLoki's OTLP endpoint, :3100/otlpEvery log, agentevals' score events included
prometheusAn endpoint on the Collector itself, port 8889, which Prometheus scrapesEvery metric
otlp_http/agentevalsagentevals, port 4318Agent runtime traces and logs only

The chart exposes 8889 on the Collector's Service as the port named metrics-export, which is the name Step 4's ServiceMonitor selects.

A.2 The metric made from spans#

The signal_to_metrics connector sits between the traces pipeline, as an exporter, and the metrics pipeline, as a receiver. For each span that matches its condition it records one sample of a histogram named gen_ai.invoke_agent.duration, in seconds, from the span's start and end times. Prometheus exposes it as gen_ai_invoke_agent_duration_seconds.

SettingValue
ConditionThe span's gen_ai.operation.name is invoke_agent, and its instrumentation scope is neither github.com/kagent-dev/kagent/go/adk/pkg/a2a/server nor kagent.core.a2a
Labels from the spangen_ai.agent.name, gen_ai.request.model, error.type, each when present
Labels from the resourceservice.name, and when present service.namespace, service.version, kagent.runtime, gen_ai.main_agent.id
Buckets0.5, 1, 2, 5, 10, 30, 60, 120 and 300 seconds

A.3 The processors#

ProcessorPipelinesWhat it does
batchAllGroups telemetry before export. It is why a turn takes a few seconds to appear
delta_to_cumulativemetricsConverts delta metrics to cumulative ones, which is what Prometheus expects
transform/harness_native_genaitracesOn spans from a resource whose kagent.genai.producer is runtime, and whose llm_request.context is not standalone, deletes the attributes gen_ai.operation.name, gen_ai.system, gen_ai.request.model, gen_ai.response.finish_reasons and gen_ai.usage.*
filter/agent_runtimes_onlytraces/agentevals, logs/agentevalsDrops every span and log record whose resource has no kagent.runtime attribute
filter/kagent_taskstoretraces/agentevalsDrops spans whose RPC method or name starts with kagent.runtime.v1.TaskStoreService/

The two filters exist for agentevals. It groups spans into sessions by gen_ai.conversation.id and falls back to the trace ID, so without the first filter every Substrate, gateway and controller background trace would show up as a session. kagent writes a TaskStore RPC span for each streamed chunk, and agentevals keeps only the first 10,000 spans of a trace, so without the second a long turn could lose its invoke_agent span.

A.4 The Prometheus endpoint#

SettingWhy
metric_expiration: 60mThe default, 5 minutes, drops a series five minutes after its last update, so each burst of agent turns would start a new series and rate() and increase() would miss turns
resource_to_telemetry_conversion.enabled: trueCopies each resource's attributes onto its metrics as labels. It is why every metric through the Collector has a service_name label

Attachment B: Two agents on two models#

The guide scores one agent against itself, which measures how much it varies from run to run. The same steps answer a different question: is a cheaper model good enough? Declare two agents with the same prompt and tools on different models, take the stronger model's session as the golden run, and score the cheaper one against it.

This path needs a key with access to gpt-4.1.

B.1 The agents#

k8s-agent runs on gpt-4.1 and is the golden run. k8s-agent-mini runs on the default ModelConfig and is scored against it. Both reuse the OpenAI key in the default-model-config Secret, run on the kagent Harness, and get only read-only Kubernetes tools from kagent-tool-server:

kubectl apply -f- <<'EOF'
apiVersion: api.kagent.dev/v1alpha3
kind: ModelConfig
metadata:
name: gpt-41
namespace: kagent
spec:
provider: OpenAI
model: gpt-4.1
apiKeySecret: default-model-config
apiKeySecretKey: OPENAI_API_KEY
stream: true
---
apiVersion: api.kagent.dev/v1alpha3
kind: Agent
metadata:
name: k8s-agent
namespace: kagent
spec:
harnessRef:
name: kagent
template:
inline:
description: Read-only Kubernetes assistant on gpt-4.1 (golden run for agentevals).
modelConfig:
name: gpt-41
systemPrompt: You are a Kubernetes assistant. Use your tools to answer questions about the cluster. Keep answers short.
tools:
- mcp:
server:
kind: RemoteMCPServer
name: kagent-tool-server
tools:
- k8s_get_resources
- k8s_describe_resource
- k8s_get_events
- k8s_get_pod_logs
---
apiVersion: api.kagent.dev/v1alpha3
kind: Agent
metadata:
name: k8s-agent-mini
namespace: kagent
spec:
harnessRef:
name: kagent
template:
inline:
description: Read-only Kubernetes assistant on gpt-4.1-mini (scored against k8s-agent).
modelConfig:
name: default-model-config
systemPrompt: You are a Kubernetes assistant. Use your tools to answer questions about the cluster. Keep answers short.
tools:
- mcp:
server:
kind: RemoteMCPServer
name: kagent-tool-server
tools:
- k8s_get_resources
- k8s_describe_resource
- k8s_get_events
- k8s_get_pod_logs
EOF
kubectl wait agent/k8s-agent agent/k8s-agent-mini -n kagent --for=condition=Ready --timeout=300s

B.2 The sessions#

The same loop as Step 13, over both agents:

forwards
AGENTS=(k8s-agent k8s-agent-mini)
RUNS=2
for agent in "${AGENTS[@]}"; do
for run in $(seq 1 "$RUNS"); do
session=$(kagent_cli agent session create --agent "$agent" -o json | jq -r .session.id)
echo "== $agent run $run ($session)"
kagent_cli agent invoke --session "$session" \
-t "Use your tools to list the namespaces in this cluster, then tell me how many pods are running in the kagent namespace. Answer in two short sentences."
kagent_cli agent invoke --session "$session" \
-t "Now use your tools to list the services in the agentevals namespace. One sentence."
done
done

B.3 The score#

Follow Step 14 with one change: set a k8s-agent session as the EvalSet, and read the results for the k8s-agent-mini sessions. tool_trajectory_avg_score shows whether the cheaper model called the same tools, and final_response_match_v2 whether its answers mean the same.

Attachment C: Troubleshooting#

Each entry gives the symptom, the cause and the fix. None was reproduced on purpose for this guide.

C.1 The Collector restarts in a loop and nothing reaches any backend. Cause: a regular expression in its configuration has a single backslash (\.) where it needs two (\\.), so the Collector cannot parse its configuration. An unquoted heredoc, or an editor that normalizes escapes, is enough to do it. Fix: restore the doubled backslashes in the filter/kagent_taskstore and transform/harness_native_genai processors, and run Step 4's helm-otel-collector block again. Find the line it rejected:

kubectl get pods -n telemetry -l app.kubernetes.io/instance=otel-collector
kubectl logs deployment/otel-collector -n telemetry --previous --tail=20 || true

C.2 Every trace query in Grafana fails, and Loki and Prometheus work. Cause: the Tempo data source points at port 3100. Tempo's HTTP API listens on 3200; 3100 is Loki's, and the Tempo Service has no such port. Fix: set the data source's URL to http://tempo.telemetry.svc.cluster.local:3200 in Step 3's values and run the helm-kube-prometheus-stack block again.

C.3 The Collector logs export errors for otlp_http/agentevals. Cause: its traces/agentevals and logs/agentevals pipelines send to agentevals, which is not installed yet or is not running. The other pipelines are unaffected. Fix: run Step 5, or check the evaluator:

kubectl get pods -n agentevals
kubectl get secret agentevals-judge -n agentevals -o name || echo "the agentevals-judge Secret is missing"

C.4 The agentevals pod does not start. Cause: its values load the judge's key from the agentevals-judge Secret, and the Secret does not exist. Fix: run Step 5's secret-agentevals-judge block, then helm-agentevals again. c-agentevals-state above shows both.

C.5 Agents show Ready=False with reason ActorTemplateRejected. Cause: kagent 1.0.0-rc3 and later set a golden egress policy on every ActorTemplate, and Substrate rejects it unless the GoldenEgressPolicy preview gate is on. Fix: run Step 6's helm-substrate-otel block, which sets the gate. Check what the release has:

helm get values substrate -n ate-system -o json | jq -c '.preview'
kubectl get agents -n kagent -o custom-columns='NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,REASON:.status.conditions[?(@.type=="Ready")].reason'

C.6 The kagent upgrade in Step 7 fails with conflict with "app" ... .spec.apiKeySecret, or points the default ModelConfig back at the chart's Secret. Cause: the model API key was changed in the kagent UI, and the upgrade re-applies the chart's default-model-config. Helm 4 reports the conflict; Helm 3 silently takes the field back. Fix: pass the current key to the chart on the same upgrade, and with Helm 4 also take the field back. This assumes the default OpenAI provider; use the providers.<provider> key that matches your install. Helm 3 has no --force-conflicts flag, so drop it there. The key is read from your shell, so this is not a block the runner executes:

helm upgrade kagent oci://ghcr.io/kagent-dev/kagent/helm/kagent \
--version ${KAGENT_VERSION} --namespace kagent --reuse-values \
--set providers.openAI.apiKey="$OPENAI_API_KEY" --force-conflicts

C.7 A chat after Step 7 leaves no trace. Cause: kagent bakes telemetry settings into each agent revision. The agent is still on the revision from before the upgrade, or the chat was opened before the new revision was ready. Fix: wait until the desired and latest revisions match, then start a new chat:

kubectl get agents -n kagent \
-o custom-columns='NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,DESIRED:.status.desiredRevision,LATEST:.status.latestSuccessfulRevision'

C.8 final_response_match_v2, hallucinations_v1 or a rubric_based_* metric fails, and the other metrics score. Cause: those metrics call a judge model, and agentevals has no key for it. Fix: check which keys it found, then run Step 5's secret-agentevals-judge block and restart it:

svc_get agentevals agentevals:8001 /api/config | jq -c '.data.apiKeys'

C.9 A check through a port-forward is refused, or a UI stops loading. Cause: the port-forward was attached to a pod that a rollout has since replaced, or something else holds the local port. Fix: run forwards again, or the forward line for Grafana (Step 12) or agentevals (Step 14). forward reports a port that something else holds; see what does:

for port in "${KAGENT_API_PORT}" "${KAGENT_UI_PORT}" "${GRAFANA_PORT}" "${AGENTEVALS_PORT}"; do
holder=$(lsof -nP -iTCP:"${port}" -sTCP:LISTEN 2>/dev/null | awk 'NR == 2 {print $1 " pid " $2}' || true)
echo "${port}: ${holder:-free}"
done