You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+[Mapping of `SeverityNumber`](#mapping-of-severitynumber)
33
-
+[Reverse Mapping](#reverse-mapping)
34
-
+[Error Semantics](#error-semantics)
35
-
+[Displaying Severity](#displaying-severity)
36
-
+[Comparing Severity](#comparing-severity)
37
-
*[Field: `Body`](#field-body)
38
-
*[Field: `Attributes`](#field-attributes)
39
-
+[Errors and Exceptions](#errors-and-exceptions)
40
-
*[Field: `EventName`](#field-eventname)
31
+
+[Field: `Body`](#field-body)
32
+
+[Field: `Attributes`](#field-attributes)
33
+
-[Errors and Exceptions](#errors-and-exceptions)
34
+
+[Field: `EventName`](#field-eventname)
35
+
-[Log Records](#log-records)
36
+
*[Logs](#logs)
37
+
*[Events](#events)
38
+
-[Severity](#severity)
39
+
*[Mapping of `Severity`](#mapping-of-severity)
40
+
+[Mapping to `SeverityNumber`](#mapping-to-severitynumber)
41
+
+[Mapping from `SeverityNumber`](#mapping-from-severitynumber)
42
+
*[Error Semantics](#error-semantics)
43
+
*[Displaying Severity](#displaying-severity)
44
+
*[Comparing Severity](#comparing-severity)
41
45
-[Example Log Records](#example-log-records)
42
46
-[Example Mappings](#example-mappings)
43
47
-[References](#references)
@@ -46,6 +50,8 @@ weight: 2
46
50
47
51
</details>
48
52
53
+
## Overview
54
+
49
55
This is a data model and semantic conventions that allow to represent logs from
50
56
various sources: application log files, machine generated events, system logs,
51
57
etc. Existing log formats can be unambiguously mapped to this data model.
@@ -102,14 +108,6 @@ The Data Model aims to successfully represent 3 sorts of logs and events:
102
108
we include in the logs. We can likely modify the source code of the
103
109
application if needed.
104
110
105
-
### Events
106
-
107
-
Events are OpenTelemetry's standardized format for LogRecords. All semantic
108
-
conventions defined for logs SHOULD be formatted as Events. Requirements and details for the Event format can be found in the [semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md).
109
-
110
-
Events are intended to be used by OpenTelemetry instrumentation. It is not a
111
-
requirement that all LogRecords are formatted as Events.
112
-
113
111
### Definitions Used in this Document
114
112
115
113
In this document we refer to types `any` and `map<string, any>`, defined as
@@ -189,38 +187,48 @@ decision about when to use a top-level named field:
189
187
Both of the above conditions were required to give the field a place in the
190
188
top-level structure of the record.
191
189
192
-
## Log and Event Record Definition
190
+
## Model Details
191
+
192
+
### Open Telemetry Protocol data model
193
+
194
+
The OpenTelemetry protocol (OTLP) data model is composed of Log data streams. These streams are in turn composed of log records.
193
195
194
-
[Appendix A](./data-model-appendix.md#appendix-a-example-mappings) contains many examples that show how
195
-
existing log formats map to the fields defined below. If there are questions
196
-
about the meaning of the field reviewing the examples may be helpful.
196
+
Log streams are grouped into individual Log objects, identified by:
197
197
198
-
Here is the list of fields in a log record:
198
+
- The originating Resource attributes
199
+
- The instrumentation Scope (e.g., instrumentation library name, version)
199
200
200
-
| Field Name | Description |
201
-
| ---------- | ----------- |
202
-
| Timestamp | Time when the event occurred. |
203
-
| ObservedTimestamp | Time when the event was observed. |
204
-
| TraceId | Request trace id. |
205
-
| SpanId | Request span id. |
206
-
| TraceFlags | W3C trace flag. |
207
-
| SeverityText | The severity text (also known as log level). |
208
-
| SeverityNumber | Numerical value of the severity. |
209
-
| Body | The body of the log record. |
210
-
| Attributes | Additional information about the event. |
211
-
| EventName | Name that identifies the class / type of event. |
201
+
The `Log` record is defined by the following properties:
202
+
203
+
| Field Name | Category | Description |
204
+
| ---------- | -------- | ----------- |
205
+
| Timestamp || Time when the event occurred. |
206
+
| ObservedTimestamp || Time when the event was observed. |
| SeverityText | Severity | The severity text (also known as log level). |
211
+
| SeverityNumber | Severity | Numerical value of the severity. |
212
+
| Body || The body of the log record. |
213
+
| Attributes || Additional information about the event. |
214
+
| EventName || Name that identifies the class / type of event. |
215
+
216
+
> [!NOTE]
217
+
> [Appendix A](./data-model-appendix.md#appendix-a-example-mappings) contains many examples that show how
218
+
> existing log formats map to the fields defined above. If there are questions
219
+
> about the meaning of the field reviewing the examples may be helpful.
212
220
213
221
Below is the detailed description of each field.
214
222
215
-
### Field: `Timestamp`
223
+
####Field: `Timestamp`
216
224
217
225
Type: Timestamp, uint64 nanoseconds since Unix epoch.
218
226
219
227
Description: Time when the event occurred measured by the origin clock, i.e. the
220
228
time at the source. This field is optional, it may be missing if the source
221
229
timestamp is unknown.
222
230
223
-
### Field: `ObservedTimestamp`
231
+
####Field: `ObservedTimestamp`
224
232
225
233
Type: Timestamp, uint64 nanoseconds since Unix epoch.
226
234
@@ -238,8 +246,6 @@ timestamp internally the following logic is recommended:
238
246
239
247
- Use `Timestamp` if it is present, otherwise use `ObservedTimestamp`.
240
248
241
-
### Trace Context Fields
242
-
243
249
#### Field: `TraceId`
244
250
245
251
Type: byte sequence.
@@ -266,8 +272,6 @@ Description: Trace flag as defined in
266
272
specification. At the time of writing the specification defines one flag - the
267
273
SAMPLED flag. This field is optional.
268
274
269
-
### Severity Fields
270
-
271
275
#### Field: `SeverityText`
272
276
273
277
Type: string.
@@ -305,7 +309,77 @@ The following table defines the meaning of `SeverityNumber` value:
305
309
306
310
`SeverityNumber=0` MAY be used to represent an unspecified value.
307
311
308
-
#### Mapping of `SeverityNumber`
312
+
#### Field: `Body`
313
+
314
+
Type: [`any`](#type-any) or [AnyValue](../common/README.md#anyvalue).
315
+
316
+
Description: A value containing the body of the log record. Can be for example
317
+
a human-readable string message (including multi-line) describing the event in
318
+
a free form or it can be a structured data composed of arrays and maps of other
319
+
values. Body MUST support [AnyValue](../common/README.md#anyvalue)
320
+
to preserve the semantics of structured logs emitted by the applications.
321
+
Can vary for each occurrence of the event coming from the same source.
322
+
This field is optional.
323
+
324
+
#### Field: `Attributes`
325
+
326
+
Type: [`map<string, any>`](#type-mapstring-any) or [Attribute Collection](../common/README.md#attribute-collections).
327
+
328
+
Description: Additional information about the specific event occurrence. Unlike
329
+
the [`Resource`](../resource/sdk.md), which is fixed for a particular source, `Attributes` can
330
+
vary for each occurrence of the event coming from the same source. Can contain
331
+
information about the request context.
332
+
This field is optional.
333
+
334
+
##### Errors and Exceptions
335
+
336
+
Additional information about errors and/or exceptions that are associated with
337
+
a log record MAY be included in the structured data in the `Attributes` section
338
+
of the record.
339
+
If included, they MUST follow the OpenTelemetry
340
+
[semantic conventions for exception-related attributes](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md).
341
+
342
+
#### Field: `EventName`
343
+
344
+
Type: string.
345
+
346
+
Description: Name that identifies the class / type of the [Event](#events).
347
+
This name SHOULD uniquely identify the event structure (both attributes and body).
348
+
A log record with a non-empty event name is an [Event](#events).
349
+
350
+
## Log Records
351
+
352
+
It is not a requirement that all LogRecords are formatted as Events hence the 2 formats described below.
353
+
354
+
> [!NOTE]
355
+
> Events are intended to be used by OpenTelemetry instrumentation.
356
+
357
+
### Logs
358
+
359
+
The requirements of logs are:
360
+
361
+
- A log MUST NOT have an event name.
362
+
- Attributes SHOULD be used to represent details and provide additional context about the event.
363
+
- Body may be used.
364
+
- Events SHOULD specify a severity number.
365
+
366
+
Logs are not defined in semantic conventions.
367
+
368
+
### Events
369
+
370
+
Events are OpenTelemetry's standardized format for LogRecords. The requirements of events are:
371
+
372
+
- An event MUST have an event name that uniquely identifies the event structure.
373
+
- Attributes SHOULD be used to represent details and provide additional context about the event.
374
+
- Events SHOULD specify a severity number.
375
+
376
+
All semantic conventions defined for logs SHOULD be formatted as Events with the requirements and details for the Event format can be found in the [semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md).
377
+
378
+
## Severity
379
+
380
+
### Mapping of `Severity`
381
+
382
+
#### Mapping to `SeverityNumber`
309
383
310
384
Mappings from existing logging systems and formats (or **source format** for
311
385
short) must define how severity (or log level) of that particular format
@@ -336,7 +410,7 @@ records with missing severity information distinctly or may interpret log
336
410
records with missing `SeverityNumber` and `SeverityText` fields as if the
337
411
`SeverityNumber` was set equal to INFO (numeric value of 9).
338
412
339
-
#### Reverse Mapping
413
+
#### Mapping from `SeverityNumber`
340
414
341
415
When performing a reverse mapping from `SeverityNumber` to a specific format
342
416
and the `SeverityNumber` has no corresponding mapping entry for that format
@@ -347,7 +421,7 @@ For example Zap has only one severity in the INFO range, called "Info". When
347
421
doing reverse mapping all `SeverityNumber` values in INFO range (numeric 9-12)
348
422
will be mapped to Zap’s "Info" level.
349
423
350
-
####Error Semantics
424
+
### Error Semantics
351
425
352
426
If `SeverityNumber` is present and has a value of ERROR (numeric 17) or higher
353
427
then it is an indication that the log record represents an erroneous situation.
@@ -364,7 +438,7 @@ recommended value in this case is INFO (numeric 9). See
364
438
[Appendix B](./data-model-appendix.md#appendix-b-severitynumber-example-mappings) for more mapping
365
439
examples.
366
440
367
-
####Displaying Severity
441
+
### Displaying Severity
368
442
369
443
The following table defines the recommended short name for each
370
444
`SeverityNumber` value. The short name can be used for example for representing
@@ -417,51 +491,13 @@ dropdown list, which lists all distinct `SeverityText` values that are known to
417
491
the system (which can be a large number of elements, often differing only in
418
492
capitalization or abbreviated, e.g. "Info" vs "Information").
419
493
420
-
####Comparing Severity
494
+
### Comparing Severity
421
495
422
496
In the contexts where severity participates in less-than / greater-than
423
497
comparisons `SeverityNumber` field should be used.
424
498
Special handling MAY be given to `SeverityNumber=0`
425
499
when it is used to represent an unspecified severity.
426
500
427
-
### Field: `Body`
428
-
429
-
Type: [`any`](#type-any) or [AnyValue](../common/README.md#anyvalue).
430
-
431
-
Description: A value containing the body of the log record. Can be for example
432
-
a human-readable string message (including multi-line) describing the event in
433
-
a free form or it can be a structured data composed of arrays and maps of other
434
-
values. Body MUST support [AnyValue](../common/README.md#anyvalue)
435
-
to preserve the semantics of structured logs emitted by the applications.
436
-
Can vary for each occurrence of the event coming from the same source.
437
-
This field is optional.
438
-
439
-
### Field: `Attributes`
440
-
441
-
Type: [`map<string, any>`](#type-mapstring-any) or [Attribute Collection](../common/README.md#attribute-collections).
442
-
443
-
Description: Additional information about the specific event occurrence. Unlike
444
-
the [`Resource`](../resource/sdk.md), which is fixed for a particular source, `Attributes` can
445
-
vary for each occurrence of the event coming from the same source. Can contain
446
-
information about the request context (other than [Trace Context Fields](#trace-context-fields)).
447
-
This field is optional.
448
-
449
-
#### Errors and Exceptions
450
-
451
-
Additional information about errors and/or exceptions that are associated with
452
-
a log record MAY be included in the structured data in the `Attributes` section
453
-
of the record.
454
-
If included, they MUST follow the OpenTelemetry
455
-
[semantic conventions for exception-related attributes](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md).
456
-
457
-
### Field: `EventName`
458
-
459
-
Type: string.
460
-
461
-
Description: Name that identifies the class / type of the [Event](#events).
462
-
This name SHOULD uniquely identify the event structure (both attributes and body).
463
-
A log record with a non-empty event name is an [Event](#events).
0 commit comments