diff --git a/public/images/blog/instrumenting-agentic-observability/agent-trace-spans.png b/public/images/blog/instrumenting-agentic-observability/agent-trace-spans.png new file mode 100644 index 00000000..b2a1e0bb Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/agent-trace-spans.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/agentevals-evaluation-results.png b/public/images/blog/instrumenting-agentic-observability/agentevals-evaluation-results.png new file mode 100644 index 00000000..43ad5545 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/agentevals-evaluation-results.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/agentevals-evaluator-config.png b/public/images/blog/instrumenting-agentic-observability/agentevals-evaluator-config.png new file mode 100644 index 00000000..304c97c0 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/agentevals-evaluator-config.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/agentevals-live-sessions.png b/public/images/blog/instrumenting-agentic-observability/agentevals-live-sessions.png new file mode 100644 index 00000000..baee67d8 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/agentevals-live-sessions.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/agentevals-set-as-evalset.png b/public/images/blog/instrumenting-agentic-observability/agentevals-set-as-evalset.png new file mode 100644 index 00000000..510ed763 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/agentevals-set-as-evalset.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/agentic-observability-questions.png b/public/images/blog/instrumenting-agentic-observability/agentic-observability-questions.png new file mode 100644 index 00000000..8d287d58 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/agentic-observability-questions.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/golden-signals-for-agents.png b/public/images/blog/instrumenting-agentic-observability/golden-signals-for-agents.png new file mode 100644 index 00000000..4f51c11d Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/golden-signals-for-agents.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/grafana-loki-agentgateway-logs.png b/public/images/blog/instrumenting-agentic-observability/grafana-loki-agentgateway-logs.png new file mode 100644 index 00000000..90a7b9cf Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/grafana-loki-agentgateway-logs.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/grafana-tempo-trace-detail.png b/public/images/blog/instrumenting-agentic-observability/grafana-tempo-trace-detail.png new file mode 100644 index 00000000..c506d34e Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/grafana-tempo-trace-detail.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/grafana-tempo-traceql.png b/public/images/blog/instrumenting-agentic-observability/grafana-tempo-traceql.png new file mode 100644 index 00000000..bd5b573d Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/grafana-tempo-traceql.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/incidents-you-know-by-heart.png b/public/images/blog/instrumenting-agentic-observability/incidents-you-know-by-heart.png new file mode 100644 index 00000000..721f3709 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/incidents-you-know-by-heart.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/then-the-agent-shipped.png b/public/images/blog/instrumenting-agentic-observability/then-the-agent-shipped.png new file mode 100644 index 00000000..9b8c59de Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/then-the-agent-shipped.png differ diff --git a/public/images/blog/instrumenting-agentic-observability/what-you-watch-agent-twin.png b/public/images/blog/instrumenting-agentic-observability/what-you-watch-agent-twin.png new file mode 100644 index 00000000..2edc6ce4 Binary files /dev/null and b/public/images/blog/instrumenting-agentic-observability/what-you-watch-agent-twin.png differ diff --git a/public/images/blog/thumbnails/instrumenting-agentic-observability.webp b/public/images/blog/thumbnails/instrumenting-agentic-observability.webp new file mode 100644 index 00000000..e56a1fb5 Binary files /dev/null and b/public/images/blog/thumbnails/instrumenting-agentic-observability.webp differ diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx index 48ca7fca..0e6b6e6d 100644 --- a/src/app/blog/page.tsx +++ b/src/app/blog/page.tsx @@ -8,6 +8,15 @@ import Github from "@/components/icons/github"; import { BlogIndex, type BlogCardPost, type Category } from "@/components/blog/blog-index"; const posts: { slug: string; publishDate: string; title: string; description: string; authorId: string; category: Category; image?: string }[] = [ + { + slug: 'instrumenting-agentic-observability', + image: '/images/blog/thumbnails/instrumenting-agentic-observability.webp', + publishDate: '2026-12-02', + title: 'Instrumenting Agentic Observability in Kagent + Agent Substrate', + description: 'Most of what you know about monitoring and observability carries over to agents, with a few new things to watch. Stand up traces, metrics, logs, and evaluations for kagent, Agent Substrate, and agentgateway with Grafana, Prometheus, Loki, Tempo, OpenTelemetry, and agentevals.', + authorId: 'michaellevan', + category: 'Tutorial', + }, { slug: 'kagent-agents-as-mcp-tasks', image: '/images/blog/thumbnails/kagent-agents-as-mcp-tasks.webp', diff --git a/src/blogContent/instrumenting-agentic-observability.mdx b/src/blogContent/instrumenting-agentic-observability.mdx new file mode 100644 index 00000000..e3e583f0 --- /dev/null +++ b/src/blogContent/instrumenting-agentic-observability.mdx @@ -0,0 +1,227 @@ +export const metadata = { + title: "Instrumenting Agentic Observability in Kagent + Agent Substrate", + publishDate: "2026-12-02T00:00:00Z", + description: + "Most of what you know about monitoring and observability carries over to agents, with a few new things to watch. Stand up traces, metrics, logs, and evaluations for kagent, Agent Substrate, and agentgateway with Grafana, Prometheus, Loki, Tempo, OpenTelemetry, and agentevals.", + author: "Michael Levan", + authorIds: ["michaellevan"], +}; + +# Instrumenting Agentic Observability in Kagent + Agent Substrate + +503's, a Worker Node goes down, a cluster needs to be scaled due to limited hardware capacity, a memory leak is causing a significant amount of RAM use… + +These are all of the things Platform/DevOps engineers and SREs see today, but how does what you're used to monitoring and observing change in the agentic era? + +In this blog post, you'll learn what you need to think about for observability with AI and how to do it with kagent + Agent Substrate. + +## The Reality Of Observability Today + +There was a time not too long ago where you'd walk into an organization and in a big room somewhere within the building, there were engineers sitting at desks with humongous monitors/TVs across the wall. What was on these monitors/TVs was the soul of the organization. Every piece of network traffic that you can think of ranging from what's coming to and leaving a server, fiber routes, regional outages, network spikes, traffic incoming through the firewall, and every other packet for ingress and egress. + +Although we don't see as many NOCs due to remote work and modern alert tooling, these are still the patterns we know by heart. + +![The incidents you know by heart in Kubernetes before agents, four failures and four signals: the app falls over (HTTP 503, CrashLoopBackOff), a node goes down (NodeNotReady, OOMKilled), memory creeps up (RSS +2% every hour), and access is denied (403 Forbidden, RBAC denied). An event log shows every signal mapping to a playbook.](/images/blog/instrumenting-agentic-observability/incidents-you-know-by-heart.png) + +And right when the industry became comfortable with understanding the ins and outs of packets flowing through the cloud, SaaS, and DevOps infrastructure, the tech overlords saw we were all getting too comfortable, said "let's throw a wrench into things" and along came Agentic AI. + +The fortunate part to that, however, is that 99% of what the industry has learned about monitoring and observability carry over to the world of agentic in the best possible ways. + +![Then the agent shipped: one support agent run told as two stories. The dashboards said healthy (pod Running, HTTP 200 OK, p99 latency 410 ms, 0.0% error rate), while what actually happened is the agent answered a refund question with the shipping policy, never saw the refund tool it needed, looped through 14 LLM calls, and burned 212k tokens on one question.](/images/blog/instrumenting-agentic-observability/then-the-agent-shipped.png) + +## Agentic Observability + +When you're running an Agent and agentic/inference infrastructure, the same rules apply to Platform/DevOps engineering observability best practices. + +- Understanding the system/platform health +- Know how your workload (in this case, an Agent) is performing +- Is the cluster/system reachable +- Are the endpoints reachable + +And everything in-between. However, there are a few new things you need to consider when observing agentic. + +![Eight questions agentic observability has to answer: did it perform as expected, how do we evaluate runs, is it going rogue, where did the request go, did the LLM have enough context, is the sandbox healthy, what can it access, and what did it cost.](/images/blog/instrumenting-agentic-observability/agentic-observability-questions.png) + +A lot of what you'll see in observing agentic, aside from the four bullet points above, is token usage, performance (both in the "did the Agent do as expected?" category and inference performance), ingress/egress to the sandbox, and context usage/compression/context efficiency. + +![A 4.2 second agent trace broken into spans (invoke_agent support, chat plan, mcp tools/list, execute_tool get_order, invoke_agent billing over A2A, chat answer, and the sandbox pod), each mapped to the questions it answers, with the gen_ai.operation.name, gen_ai.request.model, gen_ai.usage.input_tokens, and gen_ai.tool.name attributes.](/images/blog/instrumenting-agentic-observability/agent-trace-spans.png) + +What you're already looking at in a monitoring/observability platform is already great and necessary for agentic workloads, you'll just need to map to different resources for Agents, agentic workflows, and agentic/inference infrastructure. + +![A table mapping what you already watch to its agent-world twin: a crashed process to a failed or abandoned agent run, a memory leak to context bloat and runaway token use, 403 / RBAC denied to a denied or over-privileged tool call, a trace across services to a trace across agent, LLM, MCP tools and other agents, p99 latency to time to first token, tool latency and run duration, error budgets and SLOs to eval-score SLOs, and capacity planning to token budgets and cost per run.](/images/blog/instrumenting-agentic-observability/what-you-watch-agent-twin.png) + +## Implementing The Stack + +With the "why" and the "what" answered in the previous sections, let's get down to the hands-on equation of how the observability stack will be implemented. + +The stack that will get observed is: + +- kagent +- Agent Substrate +- agentgateway that runs in Agent Substrate for ingress and egress. + +The data will show traces, metrics, and logs for everything from the proxy routers ingress/egress to Agent invocations, tool executions, and evaluation results. + +### Tracing, Logs, and Metrics + +The first step is to get the observability stack up. For this, you can use the Grafana/Prometheus/Loki/Tempo stack. + +1. Save the following value files and manifests in an appropriate location for you to use: + + - Values: [https://github.com/AdminTurnedDevOps/agentic-demo-repo/tree/main/kagent-oss/v1/observability/values](https://github.com/AdminTurnedDevOps/agentic-demo-repo/tree/main/kagent-oss/v1/observability/values) + - Manifests: [https://github.com/AdminTurnedDevOps/agentic-demo-repo/tree/main/kagent-oss/v1/observability/manifests](https://github.com/AdminTurnedDevOps/agentic-demo-repo/tree/main/kagent-oss/v1/observability/manifests) + +2. Run the following to create the Namespace for your observability stack to live and install the observability stack. + + ```bash + kubectl create namespace telemetry + + helm upgrade --install tempo tempo \ + --repo https://grafana.github.io/helm-charts \ + -n telemetry -f values/tempo.yaml --wait + + helm upgrade --install loki loki \ + --repo https://grafana.github.io/helm-charts \ + -n telemetry -f values/loki.yaml --wait + + helm upgrade --install kube-prometheus-stack kube-prometheus-stack \ + --repo https://prometheus-community.github.io/helm-charts \ + -n telemetry -f values/kube-prometheus-stack.yaml --wait + + helm upgrade --install otel-collector opentelemetry-collector \ + --repo https://open-telemetry.github.io/opentelemetry-helm-charts \ + -n telemetry -f values/otel-collector.yaml --wait + + kubectl apply -f manifests/otel-collector-servicemonitor.yaml + kubectl apply -f manifests/agentgateway-podmonitor.yaml + ``` + +You should now see your observability stack running. + +```console +> kubectl get pods -n telemetry +NAME READY STATUS RESTARTS AGE +kube-prometheus-stack-grafana-76fc848b47-z8p59 3/3 Running 0 2d +kube-prometheus-stack-kube-state-metrics-645c589fb6-c4rfn 1/1 Running 0 2d +kube-prometheus-stack-operator-6bd8895578-nqhkb 1/1 Running 0 2d +loki-0 2/2 Running 0 2d +otel-collector-76896b7bb7-2pbkm 1/1 Running 0 47h +prometheus-kube-prometheus-stack-prometheus-0 2/2 Running 0 2d +tempo-0 1/1 Running 0 2d +``` + +### Evaluations + +The next step is to install and configure agentevals. The values file `agentevals.yaml` turns on evaluation events and sends them to the OTel collector. Each score lands in Loki as a `gen_ai.evaluation.result` event that carries the trace and span ID of the Agent turn. + +For evals to use "LLM as the judge", you will need an LLM API key (and you'll need it to use Agents regardless). Because of that, OpenAI is used for this, but you can use any provider you'd like. + +```bash +kubectl create namespace agentevals + +kubectl get secret default-model-config -n kagent -o jsonpath='{.data.OPENAI_API_KEY}' | base64 -d \ + | kubectl create secret generic agentevals-judge -n agentevals --from-file=OPENAI_API_KEY=/dev/stdin + +helm upgrade --install agentevals oci://ghcr.io/agentevals-dev/agentevals/helm/agentevals \ + --version 0.15.1 -n agentevals \ + -f values/agentevals.yaml --wait +``` + +You should see agentevals running in the agentevals Namespace. + +```console +> kubectl get pods -n agentevals +NAME READY STATUS RESTARTS AGE +agentevals-86d766977f-rj9xf 1/1 Running 0 46h +``` + +The Collector's traces/agentevals and logs/agentevals pipelines in `otel-collector.yaml` send agent telemetry to agentevals. Until agentevals is installed, the Collector logs export errors for them. Those pipelines only forward telemetry from agent runtimes (resources with `kagent.runtime`) + +### Agent Substrate and kagent Collector + +With the observability stack and agentevals up and running, you can now point Agent Substrate and kagent at the OTel Collector. + +```bash +helm upgrade substrate oci://ghcr.io/kagent-dev/substrate/helm/substrate \ + --version 1.0.1 -n ate-system \ + -f values/substrate.yaml --wait --timeout 10m +``` + +```bash +OTEL=http://otel-collector.telemetry.svc.cluster.local:4317 + +helm upgrade kagent oci://ghcr.io/kagent-dev/kagent/helm/kagent \ + --version "$(helm get metadata kagent -n kagent -o json | jq -r .version)" \ + -n kagent --reuse-values \ + --set-string config.telemetry.traces.endpoint=$OTEL \ + --set-string config.telemetry.metrics.endpoint=$OTEL \ + --set-string config.telemetry.logs.endpoint=$OTEL \ + --set-string config.runtimeDefaults.telemetry.traces.endpoint=$OTEL \ + --set-string config.runtimeDefaults.telemetry.metrics.endpoint=$OTEL \ + --set-string config.runtimeDefaults.telemetry.logs.endpoint=$OTEL \ + --set config.runtimeDefaults.telemetry.captureContent=true \ + --wait +``` + +## Seeing Observability In Action + +The good news about what you installed in the previous section is, as a Platform/DevOps engineer, most likely very familiar. The Grafana/Prometheus/Loki/Tempo stack has been an open-source stack around the industry for a long while and battle tested. + +With that, the same thought process you have with the rest of your infrastructure will tie in nicely to the agentic observability world. + +![New dashboard, same instincts, the golden signals for agents: latency, traffic, errors, and saturation carry over, and quality (eval score per run, tracked as an SLO) is the only new one. An example agent SLO reads: 95% of support-agent runs score at least 0.8, over 28 days.](/images/blog/instrumenting-agentic-observability/golden-signals-for-agents.png) + +### Within The Observability Stack + +1. Open up all of the dashboards. + + ```bash + kubectl port-forward -n kagent svc/kagent-ui 8081:8080 # kagent UI + kubectl port-forward -n kagent svc/kagent-controller 8083:8083 # kagent CLI + kubectl port-forward -n agentevals svc/agentevals 8001:8001 # agentevals UI + kubectl port-forward -n telemetry svc/kube-prometheus-stack-grafana 3000:80 # Grafana + ``` + +2. Generate traffic so there are sessions that come up in the observability stack and agentevals. + + ```bash + AGENTS=(smoke-agent) + RUNS=2 + + for agent in "${AGENTS[@]}"; do + for run in $(seq 1 "$RUNS"); do + session=$(kagent agent session create --agent "$agent" -o json | jq -r .session.id) + echo "== $agent run $run ($session)" + kagent 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 agent invoke --session "$session" \ + -t "Now use your tools to list the services in the agentevals namespace. One sentence." + done + done + ``` + +3. After the run, go to Explore in Grafana and use both Tempo and Loki as the data source. You'll be able to see everything from the Agent turns to the Agent Substrate calls to the traffic flowing through agentgateway and everything in-between. + + ![Grafana Explore with the Tempo data source and a TraceQL query for the smoke-agent invoke_agent spans, returning four traces from the kagent-controller service.](/images/blog/instrumenting-agentic-observability/grafana-tempo-traceql.png) + + ![A single trace opened in Grafana Tempo with 150 spans across 6 services: kagent-controller, agentgateway, the Agent Substrate API, and the smoke-agent A2A request.](/images/blog/instrumenting-agentic-observability/grafana-tempo-trace-detail.png) + + ![Grafana Explore with the Loki data source filtered to the agentgateway service, showing the logs volume and an access log line for an A2A SendStreamingMessage request routed to the Agent Substrate router.](/images/blog/instrumenting-agentic-observability/grafana-loki-agentgateway-logs.png) + +### Within Agentevals + +1. Go into agentevals and click on the Local Development button. + + ![The agentevals Live Agent Sessions page under Local Development, showing two completed sessions, each with Queue and Set as EvalSet buttons.](/images/blog/instrumenting-agentic-observability/agentevals-live-sessions.png) + +2. You'll see the two completed sessions. Choose whichever one and click the Set as EvalSet button. You'll see the purple Continue to Evaluation button pop up, click that. + + ![agentevals with one session selected as the golden run and the purple Continue to Evaluation button displayed above the completed sessions.](/images/blog/instrumenting-agentic-observability/agentevals-set-as-evalset.png) + +3. Choose what type of scoring you want to use for your evaluation. + + ![The agentevals Evaluations page with two trace files loaded, the eval set file, and the built-in evaluator configuration: tool_trajectory_avg_score under Trajectory, and response_evaluation_score, response_match_score, and final_response_match_v2 under Response.](/images/blog/instrumenting-agentic-observability/agentevals-evaluator-config.png) + +You'll now be able to see the full score of your evaluation against your two agent turns/runs. + +![The agentevals Evaluation Results page showing total traces, pass rate, and average score, with a chart of p50, p95, and p99 latency across traces.](/images/blog/instrumenting-agentic-observability/agentevals-evaluation-results.png)