Inferensys

Prompt

Trace-Based SLO Threshold Evaluation Prompt Template

A practical prompt playbook for using Trace-Based SLO Threshold Evaluation Prompt Template in production AI workflows.
Elegant overhead shot of a polished wooden communal table in a sun-drenched WeWork lounge, laptops and tablets displaying AI workflow dashboards, plants and pendant lights in background.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal scenario, required inputs, and limitations for using the Trace-Based SLO Threshold Evaluation Prompt.

This prompt is designed for AI SREs and platform engineers who need to evaluate aggregated production trace data against defined Service Level Objectives (SLOs). Use it when you have a batch of trace metrics—latency percentiles, error rates, quality scores—and you need a structured breach evaluation with severity classification. This is not a prompt for raw trace inspection or single-trace debugging. It assumes you have already extracted and aggregated metrics from your observability pipeline and need the model to apply threshold logic, classify breach severity, and produce an evaluation report suitable for an alerting system or incident review.

The prompt works best when your SLO definitions are explicit and your input data is clean. The model acts as a deterministic evaluator, not an anomaly detector. It will not discover new failure modes; it will only assess whether known thresholds have been crossed. For this reason, you must provide a complete [SLO_DEFINITIONS] block with target values, evaluation windows, and severity mappings. The input [TRACE_METRICS] should be pre-aggregated—passing raw span data will produce unreliable results. If your metrics contain gaps or incomplete dimensions, the prompt includes a requirement to flag data quality issues rather than silently producing a clean evaluation.

Do not use this prompt for real-time alerting on individual traces; it is designed for batch evaluation over a defined window. For real-time use cases, deploy the threshold logic directly in your metrics pipeline and use this prompt only for periodic review or incident postmortem analysis. Avoid using this prompt when SLO definitions are still being negotiated—the model will apply whatever thresholds you provide without questioning their business validity. For threshold tuning and calibration, use the companion Alert Threshold Tuning Recommendation Prompt Template instead.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use it to evaluate trace-based SLO thresholds, but avoid it when raw data is missing or decisions require human judgment.

01

Good Fit: Automated SLO Breach Detection

Use when: You have structured trace data with latency, error rate, and quality metrics and need automated severity classification. Guardrail: Ensure the prompt receives pre-aggregated metric windows rather than raw span dumps to prevent context-window overflow.

02

Bad Fit: Incident Root-Cause Analysis

Avoid when: The task requires correlating multiple traces, infrastructure metrics, and deployment events to find a root cause. Guardrail: Route to a dedicated incident correlation prompt instead. This prompt evaluates thresholds, not causal graphs.

03

Required Inputs: Structured Trace Metrics

What to watch: The prompt will hallucinate or produce unreliable classifications if given raw, unstructured trace logs. Guardrail: Provide pre-computed P50/P95/P99 latency, error counts, and quality scores in a defined schema. Validate input shape before calling the model.

04

Operational Risk: False-Positive Alert Storms

What to watch: Overly sensitive thresholds or miscalibrated evaluation windows can flood on-call channels with false positives. Guardrail: Implement a cooldown period and require the prompt to output a confidence score. Suppress alerts below a configurable confidence floor.

05

Operational Risk: Threshold Calibration Drift

What to watch: Static thresholds become stale as traffic patterns, model versions, and user behavior change. Guardrail: Pair this prompt with a periodic threshold tuning recommendation prompt. Log every evaluation with the threshold values used for later audit.

06

Bad Fit: Real-Time Critical Path Decisions

Avoid when: The evaluation result directly controls user-facing request routing or blocking without human review. Guardrail: Use this prompt for alert generation and dashboarding only. Human operators should acknowledge and act on severity classifications before automated remediation triggers.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for evaluating production trace spans against defined SLO thresholds and classifying breach severity.

The following prompt template is designed to be pasted directly into your evaluation harness. It accepts structured trace data, SLO definitions, and evaluation parameters, then returns a structured threshold evaluation with breach classifications. All placeholders use square brackets and must be replaced with your actual data before execution. The template assumes you have already extracted relevant spans from your observability pipeline and normalized them into the expected input schema.

text
You are an AI SRE evaluating production trace data against defined Service Level Objectives (SLOs).

Your task is to analyze the provided trace spans, compare them against the SLO thresholds, classify any breaches by severity, and return a structured evaluation.

## INPUTS

### Trace Data
[TRACE_SPANS_JSON]

### SLO Definitions
[SLO_DEFINITIONS_JSON]

### Evaluation Parameters
- Evaluation window: [EVALUATION_WINDOW]
- Current error budget remaining: [ERROR_BUDGET_REMAINING_PERCENT]
- Previous evaluation timestamp: [PREVIOUS_EVALUATION_TIMESTAMP]

## OUTPUT SCHEMA

Return a JSON object with this exact structure:
{
  "evaluation_id": "string",
  "evaluation_timestamp": "ISO8601",
  "window_start": "ISO8601",
  "window_end": "ISO8601",
  "slos_evaluated": [
    {
      "slo_name": "string",
      "metric": "latency_p95 | latency_p99 | error_rate | quality_score | token_efficiency",
      "threshold": number,
      "observed_value": number,
      "unit": "ms | percent | score",
      "breach_detected": boolean,
      "breach_severity": "critical | warning | none",
      "breach_magnitude_percent": number,
      "affected_spans": ["span_id_1", "span_id_2"],
      "contributing_factors": ["string"],
      "error_budget_consumed_percent": number
    }
  ],
  "overall_status": "healthy | degraded | critical",
  "requires_immediate_action": boolean,
  "recommended_actions": ["string"],
  "evaluation_confidence": number
}

## CONSTRAINTS

1. Classify breach severity using these rules:
   - **critical**: Observed value exceeds threshold by more than 50% OR error budget remaining is below 10%
   - **warning**: Observed value exceeds threshold by 10-50% OR error budget burn rate indicates exhaustion within [BURN_RATE_WINDOW_HOURS] hours
   - **none**: Observed value is within threshold

2. For latency SLOs, calculate percentiles from the provided span durations. If fewer than [MINIMUM_SAMPLE_COUNT] spans are available, set evaluation_confidence to "low" and note insufficient data.

3. For error rate SLOs, count spans with status "error" or "exception" against total spans in the window.

4. For quality score SLOs, use the [QUALITY_SCORE_FIELD] from span metadata. If absent, mark as unevaluable.

5. When multiple SLOs are breached, set overall_status to the highest severity among them.

6. Include specific span IDs in affected_spans to enable downstream drill-down.

7. Set evaluation_confidence between 0.0 and 1.0 based on data completeness, sample size, and measurement precision.

## EXAMPLES

Example Input:
Trace spans show 3 of 100 requests with latency > 500ms. SLO threshold is P95 < 500ms.

Example Output:
{
  "slo_name": "api-latency-p95",
  "metric": "latency_p95",
  "threshold": 500,
  "observed_value": 487,
  "unit": "ms",
  "breach_detected": false,
  "breach_severity": "none",
  "breach_magnitude_percent": 0,
  "affected_spans": [],
  "contributing_factors": [],
  "error_budget_consumed_percent": 0.5
}

## RISK LEVEL
[RISK_LEVEL]

If RISK_LEVEL is "high", append this to your response before the JSON: "HUMAN_REVIEW_REQUIRED: This evaluation contains critical breaches that may trigger incident response. A human SRE must validate before automated actions are taken."

To adapt this template for your environment, replace the trace data placeholder with spans exported from your observability platform in a consistent JSON format. Define your SLOs as a separate configuration object that maps metric names to thresholds, units, and evaluation rules. The evaluation window should align with your monitoring intervals—typically 5 minutes for real-time alerting or 1 hour for trend analysis. Before deploying, run this prompt against a set of known-good and known-breach traces to calibrate the severity classification rules against your team's incident response policies. If your risk level is high, ensure the human-review guardrail is wired into your alerting pipeline so that automated actions require explicit approval.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Validate each before sending.

PlaceholderPurposeExampleValidation Notes

[TRACE_DATA]

Raw trace spans, events, and metadata for evaluation

JSON array of OpenTelemetry-compliant spans with timestamps, durations, and attributes

Schema check: must contain required fields (trace_id, span_id, start_time, end_time). Null not allowed. Validate JSON parse succeeds before prompt assembly.

[SLO_DEFINITIONS]

Service-level objective targets and evaluation windows

{"latency_p95_ms": 500, "error_rate_percent": 0.1, "evaluation_window_minutes": 60}

Schema check: must include metric name, threshold value, and window. Validate numeric ranges (e.g., error rate 0-100). Reject missing evaluation_window.

[BASELINE_METRICS]

Historical performance data for comparison and drift detection

{"p95_latency_7d_avg_ms": 420, "error_rate_7d_avg_percent": 0.08}

Null allowed if no baseline exists. If provided, validate matching metric names against SLO_DEFINITIONS. Timestamp range check: baseline must precede evaluation window.

[ALERT_SEVERITY_MAP]

Mapping of breach magnitude to severity levels

{"warning": 1.1, "critical": 1.5, "emergency": 2.0}

Schema check: must be key-value pairs with numeric multipliers. Validate severity levels match incident response policy. Reject if emergency threshold is lower than warning.

[EVALUATION_WINDOW_END]

End timestamp for the evaluation period

2025-03-15T14:30:00Z

Format check: ISO 8601 UTC. Must be after all trace span timestamps. Null not allowed. Validate parse succeeds with datetime library before prompt assembly.

[FALSE_POSITIVE_THRESHOLD]

Acceptable false-positive rate for alert triggering

0.05

Range check: 0.0 to 1.0. Must be a float. Default to 0.05 if null. Validate against historical alert data if available.

[OUTPUT_SCHEMA]

Expected structure for threshold evaluation results

{"breaches": [...], "severity": "...", "confidence": ...}

Schema check: must be valid JSON Schema. Validate against known SLO evaluation output contract. Reject if missing required fields (breaches, severity).

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the SLO threshold evaluation prompt into a production monitoring pipeline with validation, retries, and alert routing.

This prompt is designed to be called by an automated monitoring service, not a human chat interface. The typical integration pattern is a scheduled job (e.g., a cron-triggered Cloud Function, an Airflow DAG, or a Prometheus alertmanager webhook receiver) that queries your trace store for the relevant evaluation window, assembles the prompt with the current [TRACE_DATA], [SLO_DEFINITIONS], and [EVALUATION_WINDOW] parameters, and sends the request to the model. The output is parsed and routed to your incident management system (PagerDuty, Opsgenie) or observability platform (Datadog events, Grafana annotations) based on the breach_severity field. Do not use this prompt for real-time per-request decisions; it is designed for aggregate window evaluation where a 30-60 second model latency is acceptable.

Before the prompt is called, validate that [TRACE_DATA] contains all required span attributes: service.name, duration_ms, status.code, and any custom attributes referenced in your SLO definitions (e.g., groundedness_score, tool_call_success). If the trace store query returns an empty result set, skip the model call and emit a NO_DATA status to your monitoring system to avoid false-positive breach evaluations. After the model responds, apply a strict output schema validator (Pydantic or JSON Schema) to confirm the presence of slo_id, breach_detected, breach_severity, current_value, threshold, and evaluation_timestamp for each evaluated SLO. If validation fails, implement a single retry with a backoff of 2 seconds and a slightly lowered temperature (0.0 instead of 0.1) to reduce output variance. If the retry also fails, log the raw response and escalate to the on-call channel with a PROMPT_OUTPUT_INVALID alert rather than silently dropping the evaluation.

For high-severity breach classifications (critical or major), route directly to your incident management system with the full evaluation payload attached as evidence. For minor or warning severities, write the evaluation result to your observability dashboard as a non-paging event and increment a counter metric (slo_breach_warning_total) for trend tracking. Implement a deduplication window of 5 minutes per SLO to prevent alert storms when the same threshold is breached repeatedly within a short span. Finally, log every evaluation—including non-breach results—to a structured audit table with the prompt version hash, model identifier, and raw trace window boundaries. This audit log becomes your source of truth for tuning threshold sensitivity and defending SLO compliance to stakeholders.

IMPLEMENTATION TABLE

Expected Output Contract

Schema contract for the Trace-Based SLO Threshold Evaluation prompt. Every field must be validated before the output is accepted by downstream alerting or dashboard systems.

Field or ElementType or FormatRequiredValidation Rule

evaluation_id

string (UUID v4)

Must parse as valid UUID v4. Reject if missing or malformed.

evaluation_timestamp

string (ISO 8601 UTC)

Must parse to valid UTC datetime. Reject if in the future or unparseable.

slo_name

string

Must match an entry in the [SLO_CATALOG] input. Reject if unknown.

evaluation_window

object

Must contain start_time and end_time as ISO 8601 strings. start_time must be before end_time.

observed_value

number (float)

Must be a finite number. Null not allowed. Check against [THRESHOLD_CONFIG] for expected range.

threshold_value

number (float)

Must match the threshold defined in [THRESHOLD_CONFIG] for this SLO. Reject on mismatch.

breach_detected

boolean

Must be true if observed_value violates threshold per comparison_operator. Validate logical consistency.

breach_severity

string (enum)

If breach_detected is true, must be one of: 'critical', 'warning', 'info'. Null allowed if no breach.

comparison_operator

string (enum)

Must be one of: 'greater_than', 'less_than', 'equal_to'. Must match the operator in [THRESHOLD_CONFIG].

affected_spans

array of strings

Each element must be a valid span_id from the [TRACE_DATA] input. Empty array allowed if no spans identified.

confidence_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive. Reject if outside range. Flag if below [MIN_CONFIDENCE].

evaluation_notes

string or null

If present, must be non-empty string. Null allowed. Must not contain unresolved placeholders.

PRACTICAL GUARDRAILS

Common Failure Modes

Trace-based SLO evaluation fails in predictable ways. These are the most common failure modes when evaluating latency, error rate, and quality metrics from production traces, with concrete guardrails to prevent each one.

01

Threshold Calibration Drift

What to watch: SLO thresholds defined during initial deployment become stale as traffic patterns shift, model versions change, or user behavior evolves. A 500ms P95 latency target set in January may be impossibly tight or dangerously loose by March. Guardrail: Schedule monthly threshold recalibration runs using a 30-day rolling trace window. Compare current distributions against threshold values and flag any threshold where the breach rate has shifted by more than 20% without a corresponding SLO update.

02

False-Positive Alert Storms

What to watch: Tight thresholds combined with short evaluation windows generate cascading alerts for transient spikes that self-resolve. Teams develop alert fatigue, mute channels, and miss genuine degradations. A single slow cold-start trace can trigger P95 breach alerts across multiple services. Guardrail: Require sustained breach duration (minimum 3 consecutive evaluation windows) before escalating. Implement alert deduplication that groups related span-level breaches into a single incident. Track false-positive rate weekly and tune thresholds when it exceeds 15%.

03

Silent Quality Regression

What to watch: Latency and error rate SLOs pass while output quality degrades. The model starts producing shorter, less helpful responses that stay within latency budgets, or it returns technically valid but semantically wrong outputs that don't trigger error counters. Guardrail: Always pair operational SLOs (latency, error rate) with at least one quality SLO (eval score, groundedness, citation compliance). If quality eval results aren't available in the trace, flag the trace as unevaluable rather than assuming it passed.

04

Percentile Aggregation Blindness

What to watch: P95 and P99 aggregations hide bimodal distributions where a small but consistent subset of users experiences terrible performance while aggregate SLOs stay green. Ten percent of users hitting 10-second latencies can be invisible behind a passing P95 of 800ms. Guardrail: Add P50 and P99 side-by-side in dashboards. Implement a ratio check: if P99/P50 exceeds 5x, generate a distribution anomaly alert even if the P95 threshold isn't breached. Segment by user cohort, geography, or prompt version to surface hidden tails.

05

Tool-Call Attribution Gaps

What to watch: End-to-end latency SLOs pass, but individual tool calls are failing silently or timing out after retries. The agent hides the failure behind fallback behavior, and the trace-level SLO masks the component-level degradation. Guardrail: Evaluate SLOs at the span level, not just the trace level. Define per-tool error rate and latency thresholds. If a tool's error rate exceeds 5% or its P95 latency doubles from baseline, trigger a component alert regardless of the overall trace SLO status.

06

Evaluation Window Boundary Effects

What to watch: Breaches that straddle evaluation window boundaries are split across two windows, each falling below the alert threshold. A 10-minute degradation from 12:55 to 13:05 is invisible if windows are hourly and each shows only 5 minutes of bad data. Guardrail: Use overlapping or sliding evaluation windows (e.g., evaluate every 5 minutes over a 15-minute lookback). Implement a boundary-aware check: if any contiguous breach period exceeds half the window duration, escalate even if individual windows pass.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the SLO threshold evaluation prompt before deploying it to production. Each criterion targets a specific failure mode common in trace-based threshold analysis.

CriterionPass StandardFailure SignalTest Method

Threshold Calibration Accuracy

Evaluated threshold matches the configured SLO target within a 5% tolerance

Output threshold deviates from the input [SLO_TARGET] by more than 5%

Parse the output threshold value and compare against the [SLO_TARGET] input using a numeric assertion

Breach Severity Classification

Severity level correctly maps to the breach magnitude as defined in [SEVERITY_MAP]

A minor breach is classified as critical, or a critical breach is classified as warning

Inject a trace with a known breach percentage and assert the output severity label matches the expected mapping

Evaluation Window Adherence

Analysis is confined to the time range specified in [EVALUATION_WINDOW]

Output references spans or metrics outside the start and end timestamps in [EVALUATION_WINDOW]

Verify all timestamps in the output fall within the provided window bounds using a range check

Metric Aggregation Correctness

Aggregated metric value matches a manual calculation from the raw trace spans

Output reports a P95 latency that is lower than the P50, or an error rate that exceeds 100%

Calculate the expected metric from the input [TRACE_DATA] independently and assert the output value matches within a small epsilon

False-Positive Rate Monitoring

Output includes a false_positive_risk field with a value between 0.0 and 1.0 when [INCLUDE_FP_RISK] is true

The false_positive_risk field is missing, null, or outside the 0.0-1.0 range when explicitly requested

Validate the output schema for the presence, type, and range of the false_positive_risk field

Input Trace Completeness Handling

Output explicitly flags missing required fields in [TRACE_DATA] with a completeness_warnings array

Prompt silently computes an incorrect metric from incomplete spans without any warning

Provide a [TRACE_DATA] payload with a missing latency field and assert the output contains a non-empty completeness_warnings array

Output Schema Compliance

Output is valid JSON that matches the [OUTPUT_SCHEMA] definition exactly

Output is missing required fields, contains extra fields not in the schema, or uses incorrect types

Validate the output string against the [OUTPUT_SCHEMA] using a JSON Schema validator and assert no errors are returned

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base SLO evaluation prompt but replace strict schema validation with descriptive output expectations. Use a single evaluation window and hardcode threshold values directly in the prompt instead of passing them as variables. Focus on getting correct severity classification logic before adding production infrastructure.

code
Evaluate the following trace data against these SLO thresholds:
- Latency P95: [THRESHOLD_MS]ms
- Error rate: [THRESHOLD_PCT]%
- Quality score minimum: [MIN_SCORE]

Trace data: [TRACE_JSON]

Classify any breaches as WARNING or CRITICAL and explain why.

Watch for

  • Threshold values that are too tight or too loose for your actual traffic patterns
  • Missing edge cases where multiple SLOs breach simultaneously
  • Overly verbose explanations that would be hard to parse in a dashboard widget
  • No handling of missing trace fields or incomplete span data
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.