Skip to content

Templates API

Template-level operations. Drain3 groups raw messages into log templates; the API exposes template statistics and priority overrides.

The templates endpoints live under /api/logs/meta/… in the logs router.


Endpoint Summary

Method Path Description
GET /api/logs/meta/templates Top templates by occurrence count
PATCH /api/logs/{event_id}/priority Override an event's priority (propagates to template)

Top Templates

GET /api/logs/meta/templates?limit=20
Query Type Default Constraints
limit int 20 ≤ 200

Returns templates ordered by occurrence_count descending:

[
  {
    "template_id": "a1b2c3d4-…",
    "template": "Connection timeout connecting to {host}",
    "occurrence_count": 482113,
    "severity": "ERROR",
    "priority": "P2",
    "confidence": 0.92,
    "model_version": "roberta-v3"
  }
]

Override Event Priority (human correction)

PATCH /api/logs/{event_id}/priority
{ "priority": "P1", "reason": "Impacted production payments" }

Human corrections override the ML prediction and:

  1. Set the event's priority to the corrected value
  2. Set priority_confidence = 1.0 and model_version = "manual"
  3. Store tags.correction_reason (≤ 200 chars) on the event
  4. Propagate to template_priority so future events from the same template use the corrected priority
  5. Invalidate the Redis cache key ml:priority:{template_id}
Field Type Required Description
priority string yes P1 – P4
reason string no Optional justification

This feedback loop is what makes the Labeling Pipeline and priority correction workflow work.