Correlation, deduplication, and routing can only work on events that look alike, so every event is first turned into one shape and given the context a person needs. Normalisation parses each source's format into one schema: the same field names, timestamps in UTC, one severity scale mapped explicitly per source, and a stable fingerprint. Enrichment then resolves the resource to a service, and adds the owner, the on-call rota, the runbook, the dependency tier, and recent changes. This lesson follows one event from a monitoring source to the owning team's pager and shows two failures: a resource the service catalogue does not know, and a source whose severity scale runs the other way.
Difficulty: Advanced · Know this first: Lesson 329, Lesson 205
By the end of this lesson you can work at four levels:
This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.
This bar adds up seconds from the event to the owning on-call holding an alert they can act on. It is a worked example, not a measurement. The severity and resolution hops decide whether the alert reaches the right person at the right urgency.
Pick how resources are resolved to services, how severity is mapped, and how timestamps arrive. The readouts are for a stream of 1,000 events an hour from six sources.
Three questions. No score is saved anywhere — this is just you against the material.
Normalisation and enrichment grow in four levels: one schema, explicit mappings, complete ownership, and a pipeline run as a product.
At the basic level every event has the same fields.
Where it breaks: each source keeps its own field names, and every rule downstream needs a case per source.
Try it: Basic
A source sends "2026-11-28 09:14:03" with no offset. What do you do?
Now do it: List your sources and whether each sends an offset.
At the intermediate level every source has a tested mapping.
Try it: Intermediate
A vendor changes its severity labels in an update. How should you find out?
Now do it: Add an unmapped-severity counter to your pipeline.
At the advanced level nearly every event reaches an owner.
Try it: Advanced
Unresolved events keep coming from new namespaces. What fixes it for good?
Now do it: Write a policy that rejects pods without a service label.
At the master level the pipeline has SLOs and owners.
Trade-off: strict schemas and rejected values mean more integration work for each new source; loose ones push the work onto every responder, at 3 a.m.
Try it: Master
What single number best shows enrichment is working?
Now do it: Measure owner and runbook coverage for last month's pages.
A severity table and a resolution chain, sketched in Python (an event pipeline such as Vector, Logstash, the OpenTelemetry Collector, or an AIOps platform does this as configuration):
SEVERITY = {
"alertmanager": {"critical": "critical", "warning": "warning", "info": "info"},
"syslog": {0: "critical", 1: "critical", 2: "critical", 3: "high", 4: "warning", 5: "info", 6: "info", 7: "info"},
}
def severity(source, value):
table = SEVERITY.get(source)
if table is None or value not in table:
unmapped.labels(source=source).inc() # counted and alerted, never guessed
return "high" # conservative default: a person looks at it
return table[value]
def resolve(event, catalogue):
for rule, key in (("label", event.labels.get("service")),
("namespace", catalogue.by_namespace.get(event.labels.get("namespace"))),
("tag", catalogue.by_tag.get(event.tags.get("service")))):
if key:
return key, rule
return None, "unresolved" # to the catalogue owner's queue
Syslog's PRI value at the start of a line, such as <26>, is the facility times eight plus the severity: 26 is facility 3 (daemon) and severity 2 (critical). The numeric severities are defined in RFC 5424.
For Kubernetes, the recommended labels (app.kubernetes.io/name, app.kubernetes.io/part-of) and OpenTelemetry's service.name resource attribute give events a service at the source, which makes the catalogue lookup a fallback instead of the main path.
This is a composite of a failure pattern that keeps repeating; the details are illustrative. A ticket for a full disk.
A severity table per source, required before a source is accepted; unmapped values counted and sent to people at high severity by default; tests for each table's edge values; and a check that every paged alert carries an owner and a runbook.
Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.
Before you start: Linux with jq (sudo apt install jq), awk, GNU date, and Python 3.
Type each one, read what it prints, and compare it with the note above it.
Write two sources in their own formats (an Alertmanager webhook and syslog lines), and a small service catalogue.
mkdir -p ~/labs/events && cd ~/labs/events
cat > alertmanager.json <<'EOF'
{"alerts": [
{"labels": {"alertname": "NodeFilesystemAlmostFull", "severity": "critical", "namespace": "orders-prod", "pod": "orders-api-7c9d"}, "startsAt": "2026-11-28T09:14:03Z"},
{"labels": {"alertname": "KubePodCrashLooping", "severity": "warning", "namespace": "payments-v2", "pod": "checkout-v2-5f1a"}, "startsAt": "2026-11-28T09:15:40Z"}
]}
EOF
printf '%s\n' '<26>Nov 28 10:14:03 db-07 postgres-disk: /var/lib/pgsql 96% full' '<30>Nov 28 10:14:09 db-07 systemd: Started session cleanup' '<11>Nov 28 10:15:12 web-03 nginx: upstream connect failure' > syslog.log
printf '%s\n' 'namespace:orders-prod,orders,team-orders,disk-full' 'host:db-07,orders-db,team-orders,pg-disk' 'host:web-03,web,team-web,nginx-upstream' > catalogue.csv
lsNormalise the Alertmanager events into common fields: time, source, namespace, resource, alert name, and severity.
jq -r '.alerts[] | [.startsAt, "alertmanager", .labels.namespace, .labels.pod, .labels.alertname, .labels.severity] | @tsv' alertmanager.json
Decode syslog's PRI value into facility and severity, and map the severity with an explicit table, where a smaller number is worse.
Changes a real system: Severity tables are code: review them, test their edge values, and count the values they do not cover instead of guessing.
awk 'BEGIN { split("critical critical critical high warning info info info", S, " ") }
match($0, /^<[0-9]+>/) { pri = substr($0, 2, RLENGTH - 2); sev = pri % 8
print $4, "pri=" pri, "facility=" int(pri / 8), "severity=" sev, "->", S[sev + 1] }' syslog.logConvert the syslog time to UTC, and see what losing the offset does to it.
for t in '2026-11-28 10:14:03 +0100' '2026-11-28 10:14:03 +0000'; do date -u -d "$t" +%Y-%m-%dT%H:%M:%SZ; done
Enrich each resource from the catalogue, and list the ones that resolve to no service.
Changes a real system: An unresolved resource is a defect in the catalogue or in tagging. Fix it there, and require a service label when workloads are created.
printf '%s\n' namespace:orders-prod namespace:payments-v2 host:db-07 host:web-03 > keys.txt
awk -F, 'NR == FNR { svc[$1] = "service=" $2 " owner=" $3 " runbook=" $4; next }
{ print $1, ($1 in svc ? svc[$1] : "UNRESOLVED -> catalogue owner queue") }' catalogue.csv keys.txtnormalise.pyThis program normalises events from Alertmanager and syslog into one schema with UTC times, maps severity with a table per source (counting values the table does not cover), resolves each resource to a service by label, namespace, and host, compares the syslog severities with the wrong "higher is worse" assumption, and fingerprints, deduplicates, and routes the result. Save it as normalise.py, then run it.
# normalise.py
import hashlib
import json
import re
from datetime import datetime, timezone
ALERTMANAGER = json.loads("""{"alerts": [
{"labels": {"alertname": "NodeFilesystemAlmostFull", "severity": "critical", "namespace": "orders-prod", "pod": "orders-api-7c9d"}, "startsAt": "2026-11-28T09:14:03Z"},
{"labels": {"alertname": "NodeFilesystemAlmostFull", "severity": "critical", "namespace": "orders-prod", "pod": "orders-api-7c9d"}, "startsAt": "2026-11-28T09:15:03Z"},
{"labels": {"alertname": "KubePodCrashLooping", "severity": "warning", "namespace": "payments-v2", "pod": "checkout-v2-5f1a"}, "startsAt": "2026-11-28T09:15:40Z"},
{"labels": {"alertname": "HighLatency", "severity": "page", "namespace": "search", "pod": "search-6b2e", "service": "search"}, "startsAt": "2026-11-28T09:16:00Z"}]}""")
SYSLOG = ["<26>2026-11-28T10:14:03+01:00 db-07 postgres-disk: /var/lib/pgsql 96% full",
"<30>2026-11-28T10:14:09+01:00 db-07 systemd: Started session cleanup",
"<11>2026-11-28T10:15:12+01:00 web-03 nginx: upstream connect failure"]
SEV = {"alertmanager": {"critical": "critical", "warning": "warning", "info": "info"},
"syslog": {0: "critical", 1: "critical", 2: "critical", 3: "high", 4: "warning", 5: "info", 6: "info", 7: "info"}}
NAIVE = ["info", "info", "info", "warning", "warning", "high", "critical", "critical"] # "a higher number is worse"
BY_NAMESPACE = {"orders-prod": "orders", "search": "search"}
BY_HOST = {"db-07": "orders-db", "web-03": "web"}
OWNERS = {"orders": ("team-orders", "disk-full"), "orders-db": ("team-orders", "pg-disk"),
"web": ("team-web", "nginx-upstream"), "search": ("team-search", "latency")}
def utc(ts):
return datetime.fromisoformat(ts.replace("Z", "+00:00")).astimezone(timezone.utc)
unmapped = []
def severity(source, value):
if value not in SEV[source]:
unmapped.append((source, value))
return "high" # unknown: a person looks at it
return SEV[source][value]
def resolve(labels, host=None):
if labels.get("service"):
return labels["service"], "label"
if labels.get("namespace") in BY_NAMESPACE:
return BY_NAMESPACE[labels["namespace"]], "namespace"
if host in BY_HOST:
return BY_HOST[host], "host"
return None, "unresolved"
events = []
for a in ALERTMANAGER["alerts"]:
lab = a["labels"]
svc, rule = resolve(lab)
events.append({"time": utc(a["startsAt"]), "source": "alertmanager", "resource": lab["pod"],
"alert": lab["alertname"], "severity": severity("alertmanager", lab["severity"]),
"service": svc, "rule": rule})
PRI = re.compile(r"^<(\d+)>(\S+) (\S+) ([^:]+): (.*)$")
for line in SYSLOG:
pri, ts, host, app, msg = PRI.match(line).groups()
sev = int(pri) % 8
svc, rule = resolve({}, host)
events.append({"time": utc(ts), "source": "syslog", "resource": host, "alert": app,
"severity": severity("syslog", sev), "service": svc, "rule": rule, "naive": NAIVE[sev]})
print("normalised (times in UTC):")
for e in events:
print(f" {e['time']:%H:%M:%SZ} {e['source']:<12} {e['resource']:<17} {e['alert']:<25} "
f"{e['severity']:<8} {e['service'] or '-':<10} by {e['rule']}")
print()
print("syslog severity, table versus 'a higher number is worse':")
for e in events:
if "naive" in e:
print(f" {e['resource']:<6} {e['alert']:<14} table: {e['severity']:<8} assumed: {e['naive']}")
print()
alerts = {}
for e in events:
key = "|".join([e["service"] or "unknown", e["resource"], e["alert"]])
fp = hashlib.sha256(key.encode()).hexdigest()[:12]
if fp in alerts:
alerts[fp]["count"] += 1
continue
alerts[fp] = dict(e, count=1, fp=fp)
print(f"{len(events)} events -> {len(alerts)} alerts:")
for a in alerts.values():
if a["service"] is None:
route = "catalogue owner's queue (unresolved resource)"
else:
team, runbook = OWNERS[a["service"]]
route = {"critical": f"page {team}, runbook {runbook}", "high": f"page {team}, runbook {runbook}",
"warning": f"ticket for {team}, runbook {runbook}",
"info": f"kept for correlation (owner {team})"}[a["severity"]]
print(f" {a['fp']} x{a['count']} {a['alert']:<25} -> {route}")
print()
print("unmapped severity values:", unmapped)
Run it, and you should see this output:
$ python3 normalise.py
normalised (times in UTC):
09:14:03Z alertmanager orders-api-7c9d NodeFilesystemAlmostFull critical orders by namespace
09:15:03Z alertmanager orders-api-7c9d NodeFilesystemAlmostFull critical orders by namespace
09:15:40Z alertmanager checkout-v2-5f1a KubePodCrashLooping warning - by unresolved
09:16:00Z alertmanager search-6b2e HighLatency high search by label
09:14:03Z syslog db-07 postgres-disk critical orders-db by host
09:14:09Z syslog db-07 systemd info orders-db by host
09:15:12Z syslog web-03 nginx high web by host
syslog severity, table versus 'a higher number is worse':
db-07 postgres-disk table: critical assumed: info
db-07 systemd table: info assumed: critical
web-03 nginx table: high assumed: warning
7 events -> 6 alerts:
11b9a5814f3b x2 NodeFilesystemAlmostFull -> page team-orders, runbook disk-full
c544407b53f9 x1 KubePodCrashLooping -> catalogue owner's queue (unresolved resource)
94201a2ff223 x1 HighLatency -> page team-search, runbook latency
56132fca3d91 x1 postgres-disk -> page team-orders, runbook pg-disk
469d1f07c2f0 x1 systemd -> kept for correlation (owner team-orders)
5310b8ee1773 x1 nginx -> page team-web, runbook nginx-upstream
unmapped severity values: [('alertmanager', 'page')]
The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/event-normalisation-and-alert-enrichment && cd ~/labs/event-normalisation-and-alert-enrichment) and save this as lab.sh.
#!/usr/bin/env bash
# The Linux steps of "Event Normalisation and Alert Enrichment: One Schema, an Owner, and Context Before Correlation", as one script (save it as lab.sh).
#
# ./lab.sh run every step, in order
# ./lab.sh 2 4 run only steps 2 and 4
# ./lab.sh --list list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.
STEPS=(
'Write two sources in their own formats (an Alertmanager webhook and syslog lines), and a small service catalogue.'
'Normalise the Alertmanager events into common fields: time, source, namespace, resource, alert name, and severity.'
'Decode syslog'\''s PRI value into facility and severity, and map the severity with an explicit table, where a smaller number is worse.'
'Convert the syslog time to UTC, and see what losing the offset does to it.'
'Enrich each resource from the catalogue, and list the ones that resolve to no service.'
)
step_1() {
mkdir -p ~/labs/events && cd ~/labs/events
cat > alertmanager.json <<'EOF'
{"alerts": [
{"labels": {"alertname": "NodeFilesystemAlmostFull", "severity": "critical", "namespace": "orders-prod", "pod": "orders-api-7c9d"}, "startsAt": "2026-11-28T09:14:03Z"},
{"labels": {"alertname": "KubePodCrashLooping", "severity": "warning", "namespace": "payments-v2", "pod": "checkout-v2-5f1a"}, "startsAt": "2026-11-28T09:15:40Z"}
]}
EOF
printf '%s\n' '<26>Nov 28 10:14:03 db-07 postgres-disk: /var/lib/pgsql 96% full' '<30>Nov 28 10:14:09 db-07 systemd: Started session cleanup' '<11>Nov 28 10:15:12 web-03 nginx: upstream connect failure' > syslog.log
printf '%s\n' 'namespace:orders-prod,orders,team-orders,disk-full' 'host:db-07,orders-db,team-orders,pg-disk' 'host:web-03,web,team-web,nginx-upstream' > catalogue.csv
ls
}
step_2() {
jq -r '.alerts[] | [.startsAt, "alertmanager", .labels.namespace, .labels.pod, .labels.alertname, .labels.severity] | @tsv' alertmanager.json
}
step_3() {
awk 'BEGIN { split("critical critical critical high warning info info info", S, " ") }
match($0, /^<[0-9]+>/) { pri = substr($0, 2, RLENGTH - 2); sev = pri % 8
print $4, "pri=" pri, "facility=" int(pri / 8), "severity=" sev, "->", S[sev + 1] }' syslog.log
}
step_4() {
for t in '2026-11-28 10:14:03 +0100' '2026-11-28 10:14:03 +0000'; do date -u -d "$t" +%Y-%m-%dT%H:%M:%SZ; done
}
step_5() {
printf '%s\n' namespace:orders-prod namespace:payments-v2 host:db-07 host:web-03 > keys.txt
awk -F, 'NR == FNR { svc[$1] = "service=" $2 " owner=" $3 " runbook=" $4; next }
{ print $1, ($1 in svc ? svc[$1] : "UNRESOLVED -> catalogue owner queue") }' catalogue.csv keys.txt
}
# print a step that has to be run by hand, instead of running it
by_hand() {
echo " (run this one yourself: $1)"
sed 's/^/ /'
}
RESULTS=()
run_step() {
local n=$1 start=$SECONDS code
printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
"step_$n"
code=$?
RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}
summary() {
echo
echo "== summary"
local r
for r in "${RESULTS[@]}"; do echo " $r"; done
}
case "${1:-}" in
-h|--help) sed -n '2,6p' "$0"; exit 0 ;;
--list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac
[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
echo "there is no step '$n'; try --list" >&2
exit 2
fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done
Then make it executable and run it:
chmod +x lab.sh ./lab.sh --list # the steps ./lab.sh # every step, then a summary of exit codes and times ./lab.sh 2 3 # only steps 2 and 3
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
awk, mkdir, cat, ls, cd, Pipes, Redirection, Loops, If...Else, Here documents.You are building the event pipeline in front of an AIOps platform for 40 services and six sources: Alertmanager, a cloud monitoring service, syslog, application logs, synthetic checks, and a security tool. Design normalisation and enrichment.
What is the schema, and which standard is it based on? How does each source map severity and time? How is a resource resolved to a service, and what happens when it is not? What does enrichment add, and from where? What goes into the fingerprint? How is the pipeline measured?
Say 1,000 events an hour on a normal day, 40,000 during a large incident, and a target of a page within 30 seconds of the event.
A collector with one parser and severity table per source, raw events kept for 30 days, a dead-letter queue with a size alert; a schema based on OpenTelemetry resource attributes and the Elastic Common Schema; UTC event and received times; resolution by service label, namespace in the catalogue, then cloud tags, with an admission policy requiring the label; enrichment from the catalogue, the on-call tool, and the deploy log, cached for five minutes; fingerprints from service, resource, and alert name; SLOs for resolution rate and time to page; a weekly catch-all review.
Rejecting unknown values and requiring labels slows down onboarding a new source or service; accepting everything makes the pipeline easy to join and leaves every responder to guess what an alert means.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| Unknown resource | Hop 6: Resolve | Breaks | No service label on the pod; namespace payments-v2 is not in the catalogue; no cloud tags; the naming pattern matches nothing. The alert has no service, so it has no owner, no runbook, and no rota. The catch-all rule sends it to a shared queue. |
| Unknown resource | Hop 7: Enrich | Degrades | Nothing to enrich from. |
| Unknown resource | Hop 9: Route | Breaks | In the catch-all queue for 26 minutes until a person notices it, guesses the team from the pod name, and forwards it. |
| Severity scale inverted | Hop 5: Severity | Breaks | The syslog source has no entry in the severity table, so the default rule applies: a higher number is worse, scaled to the common scale. Severity 2 out of 7 becomes info. The event that said the database disk is 96% full becomes a low-priority ticket. |
| Severity scale inverted | Hop 9: Route | Breaks | Opened as a low-priority ticket. 47 minutes later the disk fills and PostgreSQL stops accepting writes; the outage alert is what pages someone. |
The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.
Last updated . Next review due by November 2027. Found something out of date? Tell me.