@@ -24,6 +24,19 @@ They make it easy to format your logs into ECS-compatible JSON. For example:
24
24
{"@timestamp":"2019-08-06T14:08:40.199Z", "log.level":"DEBUG", "message":"init find form", "service.name":"spring-petclinic","process.thread.name":"http-nio-8080-exec-8","log.logger":"org.springframework.samples.petclinic.owner.OwnerController","transaction.id":"28b7fb8d5aba51f1","trace.id":"2869b25b5469590610fea49ac04af7da"}
25
25
----
26
26
27
+ // To do: Update these links to be documentation links
28
+ [float]
29
+ === Get started
30
+
31
+ Refer to the installation instructions of the individual loggers for
32
+ https://github.com/elastic/ecs-dotnet#logging[.NET],
33
+ Go (https://github.com/elastic/ecs-logging-go-zap[zap]),
34
+ https://www.elastic.co/guide/en/ecs-logging/java/current/setup.html[Java],
35
+ https://github.com/elastic/ecs-logging-js[JavaScript],
36
+ https://github.com/elastic/ecs-logging-php[PHP],
37
+ https://github.com/elastic/ecs-logging-python[Python],
38
+ and https://github.com/elastic/ecs-logging-ruby[Ruby].
39
+
27
40
[float]
28
41
=== Why ECS logging?
29
42
@@ -58,18 +71,6 @@ showing only the logs which belong to the corresponding request.
58
71
Vice versa, you can also jump from a log line in the Logs UI to the Span Timeline of the APM UI.
59
72
--
60
73
61
- *Broad support for languages and loggers*::
62
- +
63
- --
64
- We have loggers for https://github.com/elastic/ecs-dotnet[.NET],
65
- Go (https://github.com/elastic/ecs-logging-go-zap[zap]),
66
- https://www.elastic.co/guide/en/ecs-logging/java/current/intro.html[Java],
67
- https://github.com/elastic/ecs-logging-js[JavaScript],
68
- https://github.com/elastic/ecs-logging-php[PHP],
69
- https://github.com/elastic/ecs-logging-python[Python],
70
- and https://github.com/elastic/ecs-logging-ruby[Ruby].
71
- --
72
-
73
74
[float]
74
75
==== Additional advantages when using in combination with Filebeat
75
76
@@ -106,3 +107,100 @@ This is much more efficient than using daily indices.
106
107
--
107
108
Leverage Filebeat's default ECS-compatible {filebeat-ref}/configuration-template.html[index template].
108
109
--
110
+
111
+ [float]
112
+ === Field mapping
113
+
114
+ [float]
115
+ ==== Default fields
116
+
117
+ These fields are populated by the ECS loggers by default.
118
+ Some of them, such as the `log.origin.*` fields, may have to be explicitly enabled.
119
+ Others, such as `process.thread.name`, are not applicable to all languages.
120
+ Refer to the documentation of the individual loggers for more information.
121
+
122
+ |===
123
+ |ECS field | Description | Example
124
+
125
+ |{ecs-ref}/ecs-base.html[`@timestamp`]
126
+ |The timestamp of the log event.
127
+ |`"2019-08-06T12:09:12.375Z"`
128
+
129
+ |{ecs-ref}/ecs-log.html[`log.level`]
130
+ |The level or severity of the log event.
131
+ |`"INFO"`
132
+
133
+ |{ecs-ref}/ecs-log.html[`log.logger`]
134
+ |The name of the logger inside an application.
135
+ |`"org.example.MyClass"`
136
+
137
+ |{ecs-ref}/ecs-log.html[`log.origin.file.name`]
138
+ |The name of the file containing the source code which originated the log event.
139
+ |`"App.java"`
140
+
141
+ |{ecs-ref}/ecs-log.html[`log.origin.file.line`]
142
+ |The line number of the file containing the source code which originated the log event.
143
+ |`42`
144
+
145
+ |{ecs-ref}/ecs-log.html[`log.origin.function`]
146
+ |The name of the function or method which originated the log event.
147
+ |`"methodName"`
148
+
149
+ |{ecs-ref}/ecs-base.html[`message`]
150
+ |The log message.
151
+ |`"Hello World!"`
152
+
153
+ |{ecs-ref}/ecs-error.html[`error.type`]
154
+ |Only present for logs that contain an exception or error.
155
+ The type or class of the error if this log event contains an exception.
156
+ |`"java.lang.NullPointerException"`
157
+
158
+ |{ecs-ref}/ecs-error.html[`error.message`]
159
+ |Only present for logs that contain an exception or error.
160
+ The message of the exception or error.
161
+ |`"The argument cannot be null"`
162
+
163
+ |{ecs-ref}/ecs-error.html[`error.stack_trace`]
164
+ |Only present for logs that contain an exception or error.
165
+ The full stack trace of the exception or error as a raw string.
166
+ |`"Exception in thread "main" java.lang.NullPointerException\n\tat org.example.App.methodName(App.java:42)"`
167
+
168
+ |{ecs-ref}/ecs-process.html[`process.thread.name`]
169
+ |The name of the thread the event has been logged from.
170
+ |`"main"`
171
+
172
+ |===
173
+
174
+
175
+ [float]
176
+ ==== Configurable fields
177
+
178
+ Refer to the documentation of the individual loggers on how to set these fields.
179
+
180
+ |===
181
+ |ECS field | Description | Example
182
+
183
+ |{ecs-ref}/ecs-service.html[`service.name`]
184
+ | Helps to filer the logs by service.
185
+ |`"my-service"`
186
+
187
+ |{ecs-ref}/ecs-event.html[`event.dataset`]
188
+ | Enables the {observability-guide}/inspect-log-anomalies.html[log rate anomaly detection].
189
+ |`"my-service.log"`
190
+
191
+ |===
192
+
193
+
194
+ [float]
195
+ ==== Custom fields
196
+
197
+ Most loggers allow you to add additional custom fields.
198
+ This includes both, static and dynamic ones.
199
+ Examples for dynamic fields are logging structured objects,
200
+ or fields from a thread local context, such as `MDC` or `ThreadContext`.
201
+
202
+ When adding custom fields, we recommend using existing {ecs-ref}/ecs-field-reference.html[ECS fields] for these custom values.
203
+ If there is no appropriate ECS field,
204
+ consider prefixing your fields with `labels.`, as in `labels.foo`, for simple key/value pairs.
205
+ For nested structures, consider prefixing with `custom.`.
206
+ This approach protects against conflicts in case ECS later adds the same fields but with a different mapping.
0 commit comments