Skip to content

Commit 0a6a5d4

Browse files
committed
Adding documentation
1 parent 9d0da6a commit 0a6a5d4

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

docs/reference/enrich-processor/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ Refer to [Enrich your data](docs-content://manage-data/ingest/transform-enrich/d
8484
[`network_direction` processor](/reference/enrich-processor/network-direction-processor.md)
8585
: Calculates the network direction given a source IP address, destination IP address, and a list of internal networks.
8686

87+
[`normalize_to_otel` processor](/reference/enrich-processor/normalize-to-otel-processor.md)
88+
: Normalizes non-OpenTelemetry documents to be OpenTelemetry-compliant.
89+
8790
[`registered_domain` processor](/reference/enrich-processor/registered-domain-processor.md)
8891
: Extracts the registered domain (also known as the effective top-level domain or eTLD), sub-domain, and top-level domain from a fully qualified domain name (FQDN).
8992

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
navigation_title: "Normalize to OTel"
3+
mapped_pages:
4+
- https://www.elastic.co/guide/en/elasticsearch/reference/current/normalize-to-otel-processor.html
5+
---
6+
7+
# Normalize-to-OTel processor [normalize-to-otel-processor]
8+
9+
10+
Detects whether a document is OpenTelemetry-compliant and if not - normalizes it as described below. The resulting document can be queried seamlessly by clients that expect either [ECS](https://www.elastic.co/guide/en/ecs/current/index.html) or OpenTelemetry-[Semantic-Conventions](https://github.com/open-telemetry/semantic-conventions) formats.
11+
12+
::::{note}
13+
This processor is in tech preview and is not available in our serverless offering.
14+
::::
15+
16+
## Detecting OpenTelemetry compliance
17+
18+
The processor detects OpenTelemetry compliance by checking the following fields:
19+
* `resource` exists as a key and the value is a map
20+
* `resource` either doesn't contain an `attributes` field, or contains an `attributes` field of type map
21+
* `scope` is either missing or a map
22+
* `attributes` is either missing or a map
23+
* `body` is either missing or a map
24+
* `body` either doesn't contain a `text` field, or contains a `text` field of type `String`
25+
* `body` either doesn't contain a `structured` field, or contains a `structured` field that is not of type `String`
26+
27+
If all of these conditions are met, the document is considered OpenTelemetry-compliant and is not modified by the processor.
28+
29+
## Normalization
30+
31+
If the document is not OpenTelemetry-compliant, the processor normalizes it as follows:
32+
* Specific ECS fields are renamed to have their corresponding OpenTelemetry Semantic Conventions attribute names. These include the following:
33+
34+
| ECS Field | Semantic Conventions Attribute |
35+
|-------------|--------------------------------|
36+
| `span.id` | `span_id` |
37+
| `trace.id` | `trace_id` |
38+
| `message` | `body.text` |
39+
| `log.level` | `severity_text` |
40+
The processor first looks for the nested form of the ECS field and if such does not exist, it looks for a top-level field with the dotted field name.
41+
* Other specific ECS fields that describe resources and have corresponding counterparts in the OpenTelemetry Semantic Conventions are moved to the `resource.attribtues` map. Fields that are considered resource attributes are such that conform to the following conditions:
42+
* They are ECS fields that have corresponding counterparts (either with
43+
the same name or with a different name) in OpenTelemetry Semantic Conventions.
44+
* The corresponding OpenTelemetry attribute is defined in
45+
[Semantic Conventions](https://github.com/open-telemetry/semantic-conventions/tree/main/model)
46+
within a group that is defined as `type: enitity`.
47+
* All other fields, except from `@timestamp` are moved to the `attributes` map.
48+
* All non-array entries of the `attributes` and `resource.attributes` maps are flattened. Flattening means that nested objects are merged into their parent object, and the keys are concatenated with a dot. See examples below.
49+
50+
## Examples
51+
52+
If an OpenTelemetry-compliant document is detected, the processor does nothing. For example, the following document will stay unchanged:
53+
54+
```json
55+
{
56+
"resource": {
57+
"attributes": {
58+
"service.name": "my-service"
59+
}
60+
},
61+
"scope": {
62+
"name": "my-library",
63+
"version": "1.0.0"
64+
},
65+
"attributes": {
66+
"http.method": "GET"
67+
},
68+
"body": {
69+
"text": "Hello, world!"
70+
}
71+
}
72+
```
73+
74+
If a non-OpenTelemetry-compliant document is detected, the processor normalizes it. For example, the following document:
75+
76+
```json
77+
{
78+
"@timestamp": "2023-10-01T12:00:00Z",
79+
"service": {
80+
"name": "my-service",
81+
"version": "1.0.0",
82+
"environment": "production",
83+
"language": {
84+
"name": "python",
85+
"version": "3.8"
86+
}
87+
},
88+
"log": {
89+
"level": "INFO"
90+
},
91+
"message": "Hello, world!",
92+
"http": {
93+
"method": "GET",
94+
"url": {
95+
"path": "/api/v1/resource"
96+
},
97+
"headers": [
98+
{
99+
"name": "Authorization",
100+
"value": "Bearer token"
101+
},
102+
{
103+
"name": "User-Agent",
104+
"value": "my-client/1.0"
105+
}
106+
]
107+
},
108+
"span" : {
109+
"id": "1234567890abcdef"
110+
},
111+
"span.id": "abcdef1234567890",
112+
"trace.id": "abcdef1234567890abcdef1234567890"
113+
}
114+
```
115+
will be normalized into the following form:
116+
117+
```json
118+
{
119+
"@timestamp": "2023-10-01T12:00:00Z",
120+
"resource": {
121+
"attributes": {
122+
"service.name": "my-service",
123+
"service.version": "1.0.0",
124+
"service.environment": "production"
125+
}
126+
},
127+
"attributes": {
128+
"service.language.name": "python",
129+
"service.language.version": "3.8",
130+
"http.method": "GET",
131+
"http.url.path": "/api/v1/resource",
132+
"http.headers": [
133+
{
134+
"name": "Authorization",
135+
"value": "Bearer token"
136+
},
137+
{
138+
"name": "User-Agent",
139+
"value": "my-client/1.0"
140+
}
141+
]
142+
},
143+
"body": {
144+
"text": "Hello, world!"
145+
},
146+
"span_id": "1234567890abcdef",
147+
"trace_id": "abcdef1234567890abcdef1234567890"
148+
}
149+
```

0 commit comments

Comments
 (0)