Skip to content

Commit aaf4588

Browse files
trentmfelixbarny
andauthored
Allow "message" field to be excluded (#55)
Some logging libraries (pino for node.js, log4j2 for java) can produce log records with no message field. ECS' schema does not *require* "message" and filebeat will injest log records without a message field. Co-authored-by: Felix Barnsteiner <[email protected]>
1 parent 18cde10 commit aaf4588

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

spec/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Specification
22

3-
The specification aims to keep uniformity accross the libraries and to provide a human digestible output while producing a structured format.
3+
The specification aims to keep uniformity across the libraries and to provide a human digestible output while producing a structured format.
44

55
The ordering of the next three keys must be respected in every ecs-logging library (unless the logging framework makes this impossible):
66

77
1. `@timestamp`, base field
88
2. `log.level`, log field
9-
3. `message`, base field
9+
3. `message`, base field (if present)
1010

1111
With the fourth key, `ecs.version` ([core](https://www.elastic.co/guide/en/ecs/current/ecs-ecs.html) field) in the [ND-JSON](https://github.com/ndjson/ndjson-spec) output, we define the *minimum viable product* (MVP) for a log line.
1212
`ecs.version` must be present in case of appenders that are not adding the `ecs.version` automatically.
@@ -19,6 +19,16 @@ All other keys are not subjected to an order until decided differently and can h
1919

2020
The following example highlights the minimum set of keys in a ND-JSON output.
2121

22+
```json
23+
{
24+
"@timestamp": "2016-05-23T08:05:34.853Z",
25+
"log.level": "NOTICE",
26+
"ecs.version": "1.4.0"
27+
}
28+
```
29+
30+
Most log records will include a "message" field:
31+
2232
```json
2333
{
2434
"@timestamp": "2016-05-23T08:05:34.853Z",
@@ -28,6 +38,7 @@ The following example highlights the minimum set of keys in a ND-JSON output.
2838
}
2939
```
3040

41+
3142
### A richer Event Context
3243

3344
The following example describes a richer set of fields in an event that has not an error context (see [here](#example-error-event)). The mapping can of the example is taken from `ecs-logging-java` and can be found [here](https://github.com/elastic/ecs-logging-java#mapping).

spec/spec.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
},
3232
"message": {
3333
"type": "string",
34-
"required": true,
34+
"required": false,
3535
"index": 2,
36-
"url": "https://www.elastic.co/guide/en/ecs/current/ecs-base.html"
36+
"url": "https://www.elastic.co/guide/en/ecs/current/ecs-base.html",
37+
"comment": [
38+
"A message field is typically included in all log records, but some logging libraries allow records with no message.",
39+
"That's typically the case for libraries that allow for structured logging."
40+
]
3741
},
3842
"ecs.version": {
3943
"type": "string",

0 commit comments

Comments
 (0)