Iniciar sesión

What is ECS?

10 min · 2 ejercicio(s)

Imagine three data sources that all know the IP address of the client:

Source Field name in its own format
Firewall SRC
nginx remote_addr
Windows Security log IpAddress

To find everything an attacker's IP did, you would have to know every one of these names and write three different queries. The Elastic Common Schema (ECS) fixes this: it is an open specification that defines one name and one type for each common piece of information. In ECS all three become source.ip, of type ip.

What ECS gives you

  • One query for many sources. source.ip: 203.0.113.66 finds the address in web logs, firewall logs and authentication logs.
  • Reusable content. Kibana dashboards, the Elastic Security app, machine learning jobs and more than 1,000 prebuilt detection rules expect ECS fields. If your data follows ECS, they just work.
  • Shared vocabulary. Analysts, engineers and vendors talk about process.parent.name and mean the same thing.

You already used it

Every lab index in Querynaut follows ECS. That's why the same field names appeared in the KQL, ES|QL and EQL tracks:

FROM lab-auth, lab-endpoint, lab-web
| WHERE host.name == "srv-web-01"
| STATS events = COUNT(*) BY event.dataset

One query, three indices, one field. Without ECS this would need a different field per index.

The exception: lab-raw

The index lab-raw contains the same story as unparsed log lines. It only has the fields the shipper adds (@timestamp, message, host.name, log.file.path, event.dataset). Everything else is still hidden inside message. In module 2 you map it to ECS yourself.

How the exercises work

This track is about names, not about query languages. You'll meet three kinds of exercises:

Exercise You write Example
Field question The ECS field name source.ip
ECS mapping One line per field: rename a parsed field with ->, set a constant with = client -> source.ip, event.category = authentication
Grok / DISSECT A parsing pattern that writes directly into ECS fields from %{IP:source.ip}

The lab applies your mapping or pattern to the raw lines in lab-raw and checks with Elasticsearch whether the result has exactly the expected ECS fields and values.

ECS and OpenTelemetry

In 2023 Elastic contributed ECS to OpenTelemetry, and both are converging into one semantic convention. Most ECS field names already exist in OpenTelemetry or are on their way there, so what you learn here stays useful.

🔎 Profundiza: funciones, errores habituales y práctica

Field sets and levels

ECS groups fields into field sets such as host.*, user.*, process.*, source.*. Every field has a level:

Level Meaning
core The most common fields, expected in almost every use case (@timestamp, event.category, source.ip, host.name)
extended Everything else in the schema
custom Not ECS: your own fields, ideally in a namespace that ECS will never use

Base fields

A handful of fields live at the top level: @timestamp (required), message (the original text), tags, labels (small key/value metadata) and ecs.version, which tells consumers which ECS version a document follows.

Who populates ECS?

Elastic Agent integrations, Beats and Logstash modules map their sources to ECS in ingest pipelines. For your own applications there are ECS logging libraries (Java, .NET, Go, Node.js, Python, …) that write ECS-formatted JSON logs directly.

Ejercicios prácticos de esta lección

Resuelve estos ejercicios con una consulta en el laboratorio Elasticsearch real. Inicia sesión gratis para acceder al laboratorio, las pistas y la corrección automática.

  1. 1. Where is the attacker's address?

    In lab-auth, the brute-force address 185.220.101.47 is stored in an ECS field. The address initiated the connections. What is the field called?

  2. 2. On which machine?

    Every lab index stores the name of the machine an event happened on (for example wks-fin-07) in the same ECS field. Which one?