Inferensys

Prompt

Incident Timeline Narrative to Structured Timeline Prompt Template

A practical prompt playbook for converting postmortem narratives into structured, ordered event timelines for incident response engineers.
Incident responder handling AI system issue on laptop, logs and alerts visible, late night on-call session.
PROMPT PLAYBOOK

When to Use This Prompt

A post-generation repair workflow for converting narrative incident reports into structured, machine-readable event timelines.

This prompt is designed for incident response engineers and SRE teams who already have a free-text postmortem or incident summary generated by a model and need to force it into a strict, ordered schema. The primary job-to-be-done is extracting discrete event records—each with a timestamp, action, impact, and resolution—from a narrative that may be verbose, chronologically tangled, or missing explicit time markers. The ideal user is an engineer integrating AI-generated incident summaries into an incident management system, a time-series database, or a reporting dashboard that requires structured data, not prose. You should use this prompt when the upstream model failed to produce structured output directly, and you need a reliable repair step before ingestion.

Do not use this prompt to generate the initial incident summary from raw logs or alerts. It is not a root-cause analysis tool, nor is it designed to classify incident severity or assign ownership. It assumes the narrative already contains the relevant facts and only needs to be reorganized. The prompt is also inappropriate when the source text is too sparse to support temporal ordering—if the narrative lacks timestamps, durations, or sequential cues, the model will either hallucinate an ordering or produce records with null timestamps, both of which require downstream handling. In high-severity production incidents where timeline accuracy is critical, always pair this prompt with a human review step to verify event ordering and source grounding before the structured output enters any system of record.

Before using this prompt, ensure you have the complete narrative text, a defined output schema for your event records, and a clear understanding of which fields are required versus optional. The prompt template includes placeholders for constraints like timezone normalization and minimum required fields. After extraction, validate the output by checking that every event record can be traced back to a specific sentence or paragraph in the source narrative, that timestamps are in strictly non-decreasing order, and that no events from the source were dropped. If the narrative describes an incident spanning multiple services, consider running the prompt once per service scope to avoid interleaving errors.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Incident Timeline Narrative to Structured Timeline prompt works well—and where it introduces operational risk.

01

Good Fit: Postmortem Narratives

Use when: You have a well-written postmortem or incident report with clear chronological sections. Why: The model can map narrative paragraphs to ordered event records with high fidelity. Guardrail: Always require source-text grounding for each extracted event to prevent hallucinated timeline entries.

02

Bad Fit: Real-Time Streaming Logs

Avoid when: You need to parse raw, unstructured log streams or metrics in real time. Why: This prompt is designed for retrospective narrative synthesis, not log parsing or stream processing. Guardrail: Route raw log processing to a dedicated log parser or structured logging pipeline before any AI summarization step.

03

Required Inputs

Must have: A complete incident narrative, postmortem draft, or detailed timeline description. Critical dependency: The narrative must contain explicit timestamps or temporal markers. Guardrail: Validate input length and timestamp presence before invoking the prompt; return a clear error to the caller if the input is too sparse or lacks any temporal anchors.

04

Operational Risk: Temporal Ordering Drift

What to watch: The model may reorder events incorrectly, especially when timestamps are ambiguous or relative (e.g., 'shortly after,' 'meanwhile'). Guardrail: Implement a post-generation sort-and-validate step that checks strict chronological ordering and flags any event pair where the sequence contradicts explicit timestamps in the source.

05

Operational Risk: Event-to-Source Hallucination

What to watch: The model may invent plausible but unattested events to fill perceived gaps in the timeline. Guardrail: Require each output event to include a source_quote field; run a post-generation check that verifies every quoted string appears verbatim or in close paraphrase within the input narrative.

06

Operational Risk: Impact and Resolution Confusion

What to watch: The model may conflate impact descriptions with resolution actions, especially in compressed summaries. Guardrail: Use a strict output schema that separates impact and resolution into distinct, non-overlapping fields; add an eval check that flags records where the two fields share more than 30% token overlap.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template that converts a free-text incident narrative into a structured, ordered timeline of events with timestamps, actions, impacts, and source grounding.

This prompt is designed as a post-generation repair step. Use it when a model has already produced a free-text incident report or postmortem narrative, and you need to extract a machine-readable, chronologically ordered timeline of events. The prompt instructs the model to parse the narrative, identify discrete events, normalize timestamps, and output a strict JSON array. It is not intended for generating the initial narrative; it is a conversion harness that enforces temporal ordering and source traceability.

text
You are an incident timeline extraction engine. Your task is to convert the provided free-text incident narrative into a structured, chronologically ordered timeline of events.

## INPUT NARRATIVE
[INPUT_NARRATIVE]

## OUTPUT SCHEMA
Return a single JSON object with a key "events" containing an array of event objects. Each event object must conform to this exact schema:
{
  "event_id": "string, a unique identifier for the event (e.g., 'EVT-01')",
  "timestamp": "string, ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). If the exact time is unknown, use the most precise time available and note it in the 'certainty' field.",
  "action": "string, a concise description of what happened (max 120 characters)",
  "actor": "string, the system, service, or person responsible for the action. Use 'unknown' if not specified.",
  "impact": "string, the immediate observable consequence of the action (e.g., '503 errors increased to 15%', 'database writes blocked')",
  "status": "string, one of: 'trigger', 'escalation', 'mitigation', 'resolution', 'investigation'",
  "source_quote": "string, the exact sentence or phrase from the input narrative that provides evidence for this event",
  "certainty": "string, one of: 'exact', 'approximate', 'inferred'"
}

## CONSTRAINTS
1. **Ordering**: The "events" array MUST be sorted by "timestamp" in ascending chronological order.
2. **Grounding**: Every event MUST have a "source_quote" that is a direct, verbatim copy from the [INPUT_NARRATIVE]. Do not paraphrase.
3. **Completeness**: Extract ALL events described in the narrative. Do not summarize or omit low-severity events.
4. **No Hallucination**: Do not invent timestamps, actions, or impacts not present in the narrative. If a detail is missing, use 'unknown' for strings and 'inferred' for certainty.
5. **Temporal Consistency**: If two events have the same timestamp, order them by their logical sequence as described in the narrative.

## EXAMPLE
[FEW_SHOT_EXAMPLE]

## RISK LEVEL
[RISK_LEVEL: low | medium | high]

Now, process the INPUT NARRATIVE and return only the JSON object. Do not include any text before or after the JSON.

To adapt this template, replace the square-bracket placeholders with your specific context. The [INPUT_NARRATIVE] should contain the full free-text report. The [FEW_SHOT_EXAMPLE] is critical for teaching the model the expected level of granularity and the difference between 'trigger' and 'escalation' statuses. For high-stakes incident reviews, set [RISK_LEVEL] to 'high' and ensure a human reviews the extracted timeline against the original narrative. The source_quote field is your primary defense against hallucination—every extracted fact must be directly attributable. Before integrating this into a production pipeline, run it against a golden dataset of 20-30 incident narratives and measure exact-match accuracy on timestamps and event counts.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Incident Timeline Narrative to Structured Timeline prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to programmatically verify the input before execution.

PlaceholderPurposeExampleValidation Notes

[INCIDENT_NARRATIVE]

The full postmortem, incident report, or free-text timeline description to be converted into structured event records.

On 2024-03-15 at 14:32 UTC, the primary database cluster in us-east-1 began returning connection timeout errors. The on-call engineer was paged at 14:33...

Check: string length > 50 chars. Reject empty or whitespace-only input. Warn if input exceeds model context window minus reserved output tokens.

[TIMELINE_GRANULARITY]

The desired precision for event timestamps. Controls whether the model rounds to minutes, seconds, or keeps original precision.

second

Check: value must be one of ['second', 'minute', 'hour', 'auto']. Default to 'auto' if null. Reject unknown values before prompt assembly.

[REQUIRED_FIELDS]

A list of field names that must be present in every output event record. The model will be instructed to include these fields or mark them as null with a reason.

['timestamp_utc', 'event_type', 'description', 'impact', 'resolution_action']

Check: must be a non-empty array of strings. Each string must be a valid JSON key (alphanumeric + underscore). Reject if array contains duplicates.

[EVENT_TYPE_TAXONOMY]

A controlled vocabulary of allowed event types. The model must classify each event into one of these categories or flag it as 'other'.

['detection', 'diagnosis', 'mitigation', 'resolution', 'communication', 'escalation']

Check: must be a non-empty array of strings. Warn if taxonomy has fewer than 3 categories. Reject if taxonomy contains empty strings.

[SOURCE_GROUNDING_REQUIRED]

Boolean flag indicating whether each event must include a citation back to the source narrative. When true, the model must quote or reference the originating sentence.

Check: must be boolean true or false. If true, ensure [INCIDENT_NARRATIVE] is structured enough to support sentence-level citation. Warn if narrative is a single paragraph with no sentence breaks.

[MAX_EVENTS]

The maximum number of timeline events the model should produce. Prevents unbounded output and encourages the model to prioritize significant events.

50

Check: must be a positive integer between 5 and 200. Default to 50 if null. Warn if [INCIDENT_NARRATIVE] word count suggests more events may exist than the limit allows.

[OUTPUT_SCHEMA]

The exact JSON schema each event record must conform to. Passed as part of the prompt to enforce field types, required fields, and enum constraints.

{"type": "object", "properties": {"timestamp_utc": {"type": "string"}, "event_type": {"type": "string", "enum": [...]}}, "required": [...]}

Check: must be a valid JSON Schema object. Validate with a JSON Schema validator before prompt assembly. Reject if schema is not parseable JSON.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Incident Timeline Narrative to Structured Timeline prompt into a production application with validation, retries, and human review gates.

This prompt converts an unstructured incident narrative into a structured JSON timeline. In production, you should never trust a single model call to produce a valid, temporally consistent timeline without verification. The harness wraps the prompt in a pipeline that validates the output schema, checks temporal ordering, grounds events to source text, and escalates ambiguous or conflicting entries for human review. The prompt itself is the core transformation step, but the harness is what makes it safe to ship.

Start by defining a strict output schema using Pydantic, Zod, or JSON Schema. Each event record must include timestamp (ISO 8601), event_type (enum: detection, diagnosis, action, escalation, resolution, communication), description (string), actor (string or null), impact (string or null), source_quote (string), and confidence (enum: high, medium, low). After the model responds, run a multi-stage validator: (1) schema conformance—reject malformed JSON and retry with the repair prompt from the Malformed JSON and Structured Format Repair playbook; (2) temporal ordering—iterate through the sorted timeline and flag any event whose timestamp precedes the previous event, then route flagged sequences to a human reviewer; (3) source grounding—for each event, verify that source_quote is a verbatim substring of the input narrative using a fuzzy string match with a minimum similarity threshold of 0.85, and flag events below threshold as potentially hallucinated; (4) completeness—check that at least one event of each required event_type is present if the narrative describes a full incident lifecycle, and warn if critical phases are missing.

Wire the prompt into an incident management pipeline where it fires after a postmortem narrative is submitted. Use a model with strong JSON mode and long-context support—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are good defaults. Set temperature=0 for deterministic output. Implement a retry loop with a maximum of three attempts: if validation fails, append the specific validation errors to the retry prompt as [CONSTRAINTS] so the model can self-correct. If all retries fail, log the raw narrative and partial timeline to an internal review queue and notify the on-call engineer. For high-severity incidents, add a mandatory human approval step before the structured timeline is published to the incident record system. Store the prompt version, model version, and validation results alongside each generated timeline for auditability.

Common failure modes to monitor: the model invents timestamps when the narrative uses relative time expressions like 'an hour later' or 'by morning'—your harness should detect missing absolute timestamps and either prompt the model to infer them with explicit assumptions or flag them for human annotation. The model may also merge distinct events into one or split a single event into multiple entries; temporal ordering checks catch some of this, but periodic spot-checks against the source narrative are essential. Finally, the model may assign incorrect event_type values—for example, labeling a diagnosis step as an action—so include a few-shot examples in the prompt that clearly distinguish each type and consider adding a lightweight classification check in the harness that verifies event_type assignment against simple keyword heuristics from the source_quote.

Next steps: deploy the prompt with the validation harness in a staging environment and run it against a golden dataset of 20–30 annotated incident narratives to measure schema conformance rate, temporal ordering accuracy, and source grounding precision. Use the LLM Judge and Evaluation Rubrics playbook to build automated eval criteria. Once precision exceeds 95% and hallucination rate is below 2%, promote to production with the human review gate active for all high-severity incidents. Revisit the prompt and harness quarterly as your incident taxonomy evolves.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the fields, types, required status, and validation rules for each event record in the structured timeline array. Use this contract to build a downstream validator or to configure a retry prompt when the model output fails schema checks.

Field or ElementType or FormatRequiredValidation Rule

[EVENTS_ARRAY]

Array of objects

Must be a JSON array. Length must be >= 1. If empty, retry with explicit instruction to extract at least one event.

[EVENTS_ARRAY][*].timestamp

ISO 8601 string

Must parse to a valid datetime. If relative time is used in source, normalize to absolute ISO 8601. Fail if unparseable.

[EVENTS_ARRAY][*].event_type

Enum string

Must be one of: 'detection', 'diagnosis', 'action', 'escalation', 'resolution', 'post-incident'. Fail if value is outside this set.

[EVENTS_ARRAY][*].description

String

Must be non-empty and <= 500 characters. Must contain a verb. Fail if description is a direct copy of a previous event's description (duplicate check).

[EVENTS_ARRAY][*].source_quote

String or null

If present, must be a verbatim substring of the [INPUT_NARRATIVE]. If not present, value must be null. Fail if quote is hallucinated.

[EVENTS_ARRAY][*].impact

String or null

If present, must describe a user-facing or system-facing effect. Null allowed when impact is unknown. Fail if impact describes a future state not in source.

[EVENTS_ARRAY][*].resolved

Boolean

Must be true for event_type 'resolution', false otherwise. Fail if a non-resolution event is marked true.

[EVENTS_ARRAY][*].owner_team

String or null

If present, must match a known team label from [TEAM_LIST] or be null. Fail if value is a name rather than a team.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when converting incident narratives into structured timelines and how to guard against it.

01

Temporal Ordering Collapse

What to watch: The model outputs events in the order they appear in the narrative rather than true chronological order. This happens when the source text is written as a postmortem summary that jumps between root cause and impact. Guardrail: Add an explicit post-processing step that sorts events by timestamp and flags any event where the narrative order contradicts the extracted timestamp order for human review.

02

Timestamp Hallucination

What to watch: The model invents specific timestamps when the source only provides relative times like '30 minutes later' or 'earlier that morning.' This is the most common failure mode in incident timeline extraction. Guardrail: Require the prompt to output a timestamp_confidence field and a source_quote for every timestamp. Reject any event where the timestamp cannot be grounded to an explicit time expression in the source.

03

Causal Chain Fabrication

What to watch: The model inserts a causal relationship between events that were merely sequential in the source, turning 'A happened, then B happened' into 'A caused B.' This is especially dangerous in incident postmortems where root cause attribution has legal and operational consequences. Guardrail: Add a strict instruction that causal links require explicit language in the source. Output a separate causal_links array with required source_evidence fields, and route any inferred causation without direct textual support to human review.

04

Impact vs. Action Confusion

What to watch: The model conflates impact events with remediation actions, producing a timeline that mixes 'users experienced 503 errors' with 'team rolled back deployment' without distinguishing event types. This makes the timeline useless for blameless postmortem analysis. Guardrail: Require a required event_type enum field with values like detection, impact, diagnosis, mitigation, resolution. Validate that every event has exactly one type and that the sequence of types is plausible.

05

Missing Resolution Closure

What to watch: The timeline ends at the last mitigation action without capturing the resolution confirmation or service restoration event. This leaves the incident record incomplete and prevents accurate time-to-resolve measurement. Guardrail: Add a completeness check that verifies the final event in the timeline has an event_type of resolution and a timestamp after all mitigation events. If missing, flag the output for manual completion rather than accepting an incomplete timeline.

06

Multi-Source Timestamp Collision

What to watch: When the narrative combines monitoring alerts, chat logs, and human recollections, the model may produce conflicting timestamps for the same event without flagging the discrepancy. This creates an unreliable single source of truth. Guardrail: Instruct the model to output a conflicting_timestamps array when multiple sources disagree on when an event occurred. In the application harness, surface conflicts rather than silently picking one timestamp, and require operator resolution before the timeline is considered final.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of structured timeline outputs before shipping. Each criterion targets a specific failure mode common in narrative-to-timeline conversion.

CriterionPass StandardFailure SignalTest Method

Temporal Ordering Consistency

All events are ordered chronologically by timestamp. No event appears before a preceding event.

Events with later timestamps appear before events with earlier timestamps. Adjacent events have overlapping or impossible time ranges.

Sort output events by timestamp and verify monotonic increase. Flag any inversion with a temporal ordering assertion.

Event-to-Source Grounding

Every event in the timeline has a direct quote or explicit reference in the [INPUT_NARRATIVE]. No invented events.

An event describes an action, impact, or resolution not mentioned in the source text. Vague attributions like 'the system failed' without source evidence.

For each output event, require a source excerpt. Run a substring or fuzzy match against [INPUT_NARRATIVE]. Fail if no match found.

Timestamp Extraction Accuracy

All timestamps match the format specified in [OUTPUT_SCHEMA]. Relative times are resolved to absolute timestamps where possible.

Timestamps in wrong format, missing timezone, or unresolved relative expressions like 'later' or 'afterwards' left as-is.

Validate each timestamp against the schema regex or date parser. Flag any field that fails parsing or contains unresolved relative tokens.

Required Field Completeness

Every event record contains all fields marked Required in [OUTPUT_SCHEMA]: timestamp, event_type, description, impact, and resolution.

A required field is null, empty string, or missing from the event object. Impact or resolution fields contain placeholder text.

Iterate output events and assert presence and non-nullness of each required field. Fail if any required field is absent or empty.

Event Type Classification

Every event has an event_type value from the allowed enum in [OUTPUT_SCHEMA]: detection, diagnosis, mitigation, resolution, or communication.

An event has an event_type not in the allowed enum, or a type that contradicts the event description.

Assert that each event_type value is in the allowed enum set. Spot-check 20% of events for type-description consistency.

Impact and Resolution Pairing

Every event with impact severity 'high' or 'critical' has a corresponding resolution event later in the timeline.

A high-impact event has no follow-up resolution. Resolution events reference non-existent preceding impacts.

Build a map of high-impact events and verify each has a resolution event with matching or related description within the timeline.

Hallucinated Entity Detection

All named entities in the timeline appear in [INPUT_NARRATIVE]. No invented service names, person names, or system components.

The timeline references a service, team, or person not mentioned in the source narrative. Entity names are plausible but fabricated.

Extract all capitalized entities from output. Cross-reference against [INPUT_NARRATIVE] using exact or fuzzy match. Flag any entity with zero source occurrences.

Schema Structural Validity

The entire output parses as valid JSON matching the [OUTPUT_SCHEMA] structure. No extra fields, no missing required arrays.

Output is valid JSON but has extra top-level keys, missing the events array, or uses wrong field types.

Parse output with a JSON schema validator configured to the [OUTPUT_SCHEMA]. Fail on any structural deviation or type mismatch.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single model call and minimal post-processing. Accept the structured timeline output as-is and validate only the most critical fields: timestamp, event, and source_reference. Skip temporal ordering validation and completeness checks during early experimentation.

Simplify the output schema to a flat array of events with only required fields. Remove optional fields like confidence, impact_scope, and resolution_status until you confirm the model can reliably extract core timeline data.

Prompt snippet

code
[SYSTEM_INSTRUCTION]
Extract a timeline of events from the incident narrative below.

[OUTPUT_SCHEMA]
{
  "events": [
    {
      "timestamp": "ISO 8601 or relative time",
      "event": "brief description",
      "source_reference": "quote or paraphrase from narrative"
    }
  ]
}

Watch for

  • Events extracted out of temporal order when timestamps are ambiguous
  • Source references that paraphrase rather than quote, making verification harder
  • Missing events that span multiple paragraphs or are described implicitly
  • Model inventing timestamps for events described without explicit time markers
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.