SYSTEMS · LLM OBSERVABILITY

Sentinel

Sentinel wraps LLM calls as FastAPI middleware, tracks 16+ metrics per request, and turns Z-score anomalies into Datadog incidents with Gemini-written root cause analysis.

↓ SCROLL

The problem

Teams shipping LLM features run mostly blind. When costs spike, latency creeps up, or answer quality drops, there is no straightforward way to explain why or to catch it before users do. Token usage, spend, latency, and quality signals sit scattered across logs, so cost surges and regressions surface late and get diagnosed by hand. Sentinel targets that visibility gap for language-model applications: seeing what a model is actually doing, request by request, and being warned the moment its behavior drifts.

The approach

Sentinel sits in front of the model as a FastAPI middleware layer that records every interaction. Each request produces 16+ metrics covering tokens, cost, latency, and quality indicators, which stream to Datadog as telemetry. A detector compares each metric against a rolling baseline using Z-scores, and anything past the threshold becomes a Datadog incident with a severity level. Google Gemini then writes a plain-language root cause explanation for that incident, so the alert arrives with a first diagnosis attached instead of just a number to chase.

System design

Language / runtimePython 3.11+
Web frameworkFastAPI 0.104+
Anomaly detectionZ-score over rolling baseline (threshold 3.0, window 100 samples)
AI root cause engineGoogle Gemini
Observability + incidentsDatadog (API + App keys)
InterfacePOST /chat, GET /health, dashboard at /
DeployDocker; local or Google Cloud Run

How it works

01

Capture the request

The /chat endpoint handles the LLM call as middleware, recording 16+ metrics per request (tokens, cost, latency, quality indicators) before the response returns downstream.

02

Stream telemetry to Datadog

The telemetry layer pushes collected metrics to Datadog, building a running record of model behavior across requests.

03

Score against a baseline

The anomaly detector maintains a rolling baseline over the last 100 samples and flags any metric whose Z-score exceeds the threshold (default 3.0).

04

Open an incident

Flagged anomalies become Datadog incidents with a severity classification, so issues escalate automatically instead of waiting to be noticed.

05

Explain the root cause

Google Gemini analyzes the flagged incident and generates a plain-language root cause explanation, attaching a first diagnosis to every alert.

What it does

Per-request metrics

Tracks 16+ metrics on every call: token counts, cost, latency, and quality indicators.

Statistical anomaly detection

Uses Z-score analysis against rolling baselines to catch cost surges, latency spikes, and quality drops as they happen.

Automated Datadog incidents

Turns detected anomalies into Datadog incidents with severity levels, removing the manual triage step.

AI root cause analysis

Google Gemini writes a readable explanation of why each incident fired, so responders start from a hypothesis.

Local or Cloud Run

Ships as a Docker container that runs locally or deploys to Google Cloud Run with Datadog and Google AI credentials.

Stack

PythonFastAPIGoogle GeminiDatadogDockerGoogle Cloud Run
2025Year
SoloRole
16+Metrics / request
DatadogObservability