Normalisation and Schemas: ECS and OCSF
The VPN calls the user LAB\erin, the identity provider Erin@lab.test, Windows erin. The VPN's time is 2026-01-15 10:01:07 with no zone, the identity provider's 2026-01-15T10:02:03Z. A query for "every sign-in by erin in the last hour" written against the raw data needs three field names, three spellings and three time parsers, and the next source will need a fourth. Normalisation maps every source into one schema (common field names, types and value sets) at ingestion, so that detections are written once and work on every source that carries the same kind of event.
What a schema fixes
| Problem | Raw | Normalised |
|---|---|---|
| Field names | usr, actor.login, TargetUserName |
user.name |
| Value forms | LAB\erin, Erin@lab.test |
erin (plus user.domain if needed) |
| Outcomes | AUTH_OK, SUCCESS, event ID 4624 |
event.outcome: success |
| Timestamps | local time without zone, epoch seconds, ISO 8601 | ISO 8601 in UTC |
| Event kinds | vendor-specific | event.category: authentication |
Two schemas dominate today:
- ECS (Elastic Common Schema): dotted field names grouped into field sets (
source.*,destination.*,user.*,host.*,process.*,event.*,file.*,url.*,dns.*), with categorisation fieldsevent.kind,event.category,event.typeandevent.outcometaking values from fixed lists. Elastic contributed ECS to OpenTelemetry, whose semantic conventions are converging with it. - OCSF (Open Cybersecurity Schema Framework), backed by many security vendors and used by Amazon Security Lake: events belong to classes with numeric identifiers grouped into categories (for example the Authentication class, 3002, in the Identity & Access Management category, 3), with an
activity_id(1 = logon, 2 = logoff), astatus_id(1 = success, 2 = failure), aseverity_id, and objects such asuser,src_endpoint,dst_endpoint,actor.
Splunk's Common Information Model (CIM) and Microsoft Sentinel's ASIM do the same job inside those products. Sigma rules, which you will meet in Sigma Rules, use their own generic field names and rely on field mappings to reach whichever schema your SIEM uses.
Three sources into ECS
The session (in your sandbox, on files it writes; no network) maps three synthetic sign-in sources with jq, one small mapping per source, and then runs a single query over all of them.
cat > vpn.json <<'J'
{"ts":"2026-01-15 10:01:07","gw":"vpn01","usr":"LAB\\erin","client_ip":"198.51.100.23","result":"AUTH_FAIL"}
{"ts":"2026-01-15 10:01:40","gw":"vpn01","usr":"LAB\\erin","client_ip":"198.51.100.23","result":"AUTH_OK"}
J
cat > idp.json <<'J'
{"eventTime":"2026-01-15T10:02:03Z","actor":{"login":"Erin@lab.test"},"client":{"ip":"198.51.100.23"},"outcome":{"result":"SUCCESS"},"app":"mail"}
J
cat > win.json <<'J'
{"TimeCreated":"2026-01-15T10:05:12.000Z","Computer":"fs01.lab.test","EventID":4624,"TargetUserName":"erin","IpAddress":"10.10.0.17","LogonType":3}
J
# One mapping per source into a few ECS fields; user names lower-cased without domain.
jq -c '{"@timestamp": (.ts | sub(" "; "T") + "Z"), "event.dataset": "vpn", "event.category": "authentication",
"event.outcome": (if .result == "AUTH_OK" then "success" else "failure" end),
"user.name": (.usr | split("\\") | last | ascii_downcase), "source.ip": .client_ip, "host.name": .gw}' vpn.json > ecs.json
jq -c '{"@timestamp": .eventTime, "event.dataset": "idp", "event.category": "authentication",
"event.outcome": (.outcome.result | ascii_downcase), "user.name": (.actor.login | split("@")[0] | ascii_downcase),
"source.ip": .client.ip, "host.name": .app}' idp.json >> ecs.json
jq -c 'select(.EventID == 4624 or .EventID == 4625) | {"@timestamp": (.TimeCreated | sub("\\.000Zquot;; "Z")),
"event.dataset": "windows.security", "event.category": "authentication",
"event.outcome": (if .EventID == 4624 then "success" else "failure" end),
"user.name": (.TargetUserName | ascii_downcase), "source.ip": .IpAddress, "host.name": (.Computer | split(".")[0])}' win.json >> ecs.json
echo "== one schema, sorted by time"
jq -s -r 'sort_by(."@timestamp")[] | [."@timestamp", ."event.dataset", ."user.name", ."event.outcome", ."source.ip", ."host.name"] | join(" ")' ecs.json
echo "== one query for every source"
jq -s -r 'group_by(."user.name")[] | "\(.[0]."user.name"): \(length) events, \(map(select(."event.outcome"=="failure")) | length) failures, sources \(map(."source.ip") | unique | join(","))"' ecs.json== one schema, sorted by time
2026-01-15T10:01:07Z vpn erin failure 198.51.100.23 vpn01
2026-01-15T10:01:40Z vpn erin success 198.51.100.23 vpn01
2026-01-15T10:02:03Z idp erin success 198.51.100.23 mail
2026-01-15T10:05:12Z windows.security erin success 10.10.0.17 fs01
== one query for every source
erin: 4 events, 1 failures, sources 10.10.0.17,198.51.100.23
Once mapped, one sort and one group-by tell the story across three products: erin failed once on the VPN, succeeded, used the identity provider for mail from the same address, then logged on to the file server from her internal address 10.10.0.17. Before normalisation, that took three queries and a careful analyst; afterwards, any rule that says event.category == authentication covers all three sources.
The same event in OCSF
OCSF expresses the same facts with class and enumeration identifiers. The program maps the normalised events into minimal OCSF Authentication events (only a few of the class's attributes) and shows why numeric enumerations help: a rule can test status_id == 2 without knowing any vendor's spelling of "failure".
import json
from datetime import datetime
ecs = [
{"@timestamp": "2026-01-15T10:01:07Z", "event.dataset": "vpn", "event.outcome": "failure", "user.name": "erin", "source.ip": "198.51.100.23", "host.name": "vpn01"},
{"@timestamp": "2026-01-15T10:05:12Z", "event.dataset": "windows.security", "event.outcome": "success", "user.name": "erin", "source.ip": "10.10.0.17", "host.name": "fs01"},
]
STATUS = {"success": 1, "failure": 2} # OCSF status_id
def to_ocsf(e):
t = datetime.strptime(e["@timestamp"], "%Y-%m-%dT%H:%M:%SZ")
epoch_ms = int((t - datetime(1970, 1, 1)).total_seconds() * 1000)
return {
"class_uid": 3002, "category_uid": 3, # Authentication, Identity & Access Management
"activity_id": 1, # Logon
"type_uid": 3002 * 100 + 1, # class_uid * 100 + activity_id
"status_id": STATUS[e["event.outcome"]],
"time": epoch_ms,
"user": {"name": e["user.name"]},
"src_endpoint": {"ip": e["source.ip"]},
"dst_endpoint": {"hostname": e["host.name"]},
"metadata": {"product": {"name": e["event.dataset"]}, "version": "1.x (illustrative)"},
}
for e in ecs:
print(json.dumps(to_ocsf(e), separators=(",", ":")))
print("failed logons:", sum(1 for e in ecs if to_ocsf(e)["status_id"] == 2)){"class_uid":3002,"category_uid":3,"activity_id":1,"type_uid":300201,"status_id":2,"time":1768471267000,"user":{"name":"erin"},"src_endpoint":{"ip":"198.51.100.23"},"dst_endpoint":{"hostname":"vpn01"},"metadata":{"product":{"name":"vpn"},"version":"1.x (illustrative)"}}
{"class_uid":3002,"category_uid":3,"activity_id":1,"type_uid":300201,"status_id":1,"time":1768471512000,"user":{"name":"erin"},"src_endpoint":{"ip":"10.10.0.17"},"dst_endpoint":{"hostname":"fs01"},"metadata":{"product":{"name":"windows.security"},"version":"1.x (illustrative)"}}
failed logons: 1
Real OCSF events carry more attributes, some required (severity_id, and metadata with the product and the schema version) and many recommended or optional (the observables list, status, auth_protocol); the point here is the shape. Choose one target schema for the SIEM and map every source into it, rather than mixing schemas per source.
How normalisation errors are detected
Normalisation is code, and code has bugs that silently break detections:
- Unmapped or null fields. Count, per source and per day, how many events lack the fields detections need (
user.name,source.ip,process.command_line). A jump is a parser broken by a vendor update. - Values outside the allowed set.
event.outcomemust besuccess,failureorunknown; anything else (SUCCESS,ok) means a mapping missed a case. - Fixture tests. Keep sample raw events per source with their expected normalised output and run them whenever a parser changes, exactly like detection tests (Testing Detections).
How it is done well
- Keep the original. Store the raw event (ECS has
event.original) next to the parsed fields, so that a parser bug can be fixed and the data re-parsed, and so investigators can see exactly what the source said. - Normalise identities deliberately. Decide one canonical form (lower-case, no domain, or
user.nameplususer.domain) and map aliases (the same person's admin account, e-mail address and UPN) in an identity table (Enrichment). - Time to UTC at ingestion, with the source's zone known (Time Sync and Time Zones).
- Version the mappings in a repository with the detections that depend on them.
Pitfalls
- Lossy mapping. Squeezing a rich source into a few common fields throws away what investigators need. Map the common fields and keep the rest under a vendor namespace.
- Over-normalising outcomes. A sign-in that succeeded on the password but failed MFA is neither plain success nor plain failure; keep the reason field.
- Assuming the schema means the same thing everywhere.
source.ipbehind a load balancer or proxy is the proxy's address unless the parser reads the forwarded-for header.
Practice
1. Add a fourth source to the session: a Linux `sshd` line "Failed password for alice from 10.10.0.22". Which ECS fields does it fill?
@timestamp (from the syslog timestamp, converted to UTC), event.dataset: system.auth (or similar), event.category: authentication, event.outcome: failure, user.name: alice, source.ip: 10.10.0.22, host.name from the syslog host field; event.original keeps the line.
2. What is the OCSF `type_uid` of a failed logon and of a logoff in the Authentication class?
The type is class and activity, not status: logon is 3002 × 100 + 1 = 300201 whether it failed or succeeded (failure is status_id = 2); logoff (activity 2) is 300202.
3. A detection on `event.outcome: failure` stopped firing for VPN events last Tuesday. How would you find out why?
Count VPN events by event.outcome per day: if a new value appeared on Tuesday (for example null or a raw vendor string), the vendor changed its result codes and the mapping missed them. Look at event.original for those events, fix the mapping, add the new raw format to the parser's test fixtures, and re-parse the affected period.
Test yourself
What does normalisation give detection engineers?
- Smaller disks
- One set of field names and values, so a rule works on every source with that kind of event
- Encryption of logs
- Faster networks
In the jq session, what were the three raw spellings of the user mapped to erin?
- erin, ERIN, e.rin
- LAB\erin, Erin@lab.test and erin
- only erin
- alice, bob, erin
In OCSF, how is a failed logon distinguished from a successful one in the Authentication class?
- By a different class_uid
- By status_id (1 success, 2 failure) with the same activity_id 1
- By the event's colour
- It is not distinguished
Why keep event.original next to the parsed fields?
- It is required by TCP
- Parser bugs can be fixed and data re-parsed, and investigators see exactly what the source said
- It makes searches faster
- To duplicate storage on purpose