Skip to main content

Module normalize

Module normalize 

Source
Expand description

Log-message normalization and stable signature hashing. Message normalization for error signature detection.

normalize_template collapses variable log message parts (timestamps, IPs, IDs, hashes, numbers, JSON values, quoted strings, paths) into fixed placeholders so that repeated error patterns map to a single canonical template and, from that, a stable SHA-256 signature hash.

Design constraints:

  • No regex pipeline — pure byte/char scanner for hot-path performance.
  • Must handle multi-byte UTF-8 without splitting codepoints.
  • JSON pre-pass is highest priority (before any other replacements).

NORMALIZER_VERSION must be bumped whenever the output of normalize_template changes so that stale rows in error_signatures are not confused with new ones.

Constants§

NORMALIZER_VERSION
Bump this whenever normalize_template’s output changes for any input.

Functions§

normalize_template
Normalise a message into a template by replacing variable runs with placeholders.
signature_hash
Compute a stable SHA-256 hex digest of a normalized template.