Skip to content

Commit 70d2ba5

Browse files
adding example to otel sources data prepper (#11353)
* adding example to otel sources data prepper Signed-off-by: Anton Rubin <[email protected]> * removing - from examples Signed-off-by: Anton Rubin <[email protected]> * removing custom port Signed-off-by: Anton Rubin <[email protected]> * fixing vale errors Signed-off-by: Anton Rubin <[email protected]> * Update otel-logs-source.md Signed-off-by: AntonEliatra <[email protected]> * Update otel-logs-source.md Signed-off-by: AntonEliatra <[email protected]> * Update otel-logs-source.md Signed-off-by: AntonEliatra <[email protected]> * Apply suggestions from code review Signed-off-by: kolchfa-aws <[email protected]> --------- Signed-off-by: Anton Rubin <[email protected]> Signed-off-by: AntonEliatra <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> Co-authored-by: kolchfa-aws <[email protected]>
1 parent 9c0de56 commit 70d2ba5

File tree

1 file changed

+118
-3
lines changed

1 file changed

+118
-3
lines changed

_data-prepper/pipelines/configuration/sources/otel-logs-source.md

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,133 @@ To get started, create a `pipeline.yaml` file and add `otel_logs_source` as the
5151

5252
```yaml
5353
source:
54-
- otel_logs_source:
54+
otel_logs_source:
5555
```
56+
{% include copy.html %}
5657
5758
To generate data in the OpenTelemetry format, set the `output_format` setting to `otel`, as shown in the following example:
5859

5960
```yaml
6061
source:
61-
- otel_logs_source:
62-
output_format: otel
62+
otel_logs_source:
63+
output_format: otel
64+
```
65+
{% include copy.html %}
66+
67+
## Example
68+
69+
The following pipeline shows Data Prepper receiving OTLP logs over HTTPS using a PEM certificate and key, with unframed HTTP at a custom path, accepting gzip-compressed payloads, and indexing them into OpenSearch using the OpenTelemetry field schema:
70+
71+
```yaml
72+
otel-logs-otel-output:
73+
source:
74+
otel_logs_source:
75+
ssl: true
76+
sslKeyFile: /usr/share/data-prepper/certs/dp-key.pem
77+
sslKeyCertChainFile: /usr/share/data-prepper/certs/dp-cert.pem
78+
unframed_requests: true
79+
path: /ingest/${pipelineName}/v1/logs
80+
compression: gzip
81+
output_format: otel
82+
request_timeout: 15000
83+
health_check_service: true
84+
proto_reflection_service: true
85+
sink:
86+
- opensearch:
87+
hosts: ["https://opensearch:9200"]
88+
index: otel-logs-otel-output
89+
username: admin
90+
password: admin_pass
91+
insecure: true
92+
```
93+
{% include copy.html %}
94+
95+
You can test this pipeline using the following commands:
96+
97+
```bash
98+
cat > /tmp/otel-log3.json <<'JSON'
99+
{
100+
"resourceLogs": [{
101+
"resource": {"attributes":[
102+
{"key":"service.name","value":{"stringValue":"checkout"}},
103+
{"key":"service.version","value":{"stringValue":"1.4.2"}}
104+
]},
105+
"scopeLogs": [{
106+
"scope": {"name":"manual-gzip"},
107+
"logRecords": [{
108+
"timeUnixNano": "1739999999000000000",
109+
"severityText": "ERROR",
110+
"body": {"stringValue":"payment gateway timeout"},
111+
"attributes":[
112+
{"key":"region","value":{"stringValue":"eu-west-1"}},
113+
{"key":"latency_ms","value":{"doubleValue":1234.5}}
114+
]
115+
}]
116+
}]
117+
}]
118+
}
119+
JSON
120+
121+
gzip -c /tmp/otel-log3.json > /tmp/otel-log3.json.gz
122+
123+
curl -s -X POST "https://localhost:21892/ingest/otel-logs-otel-output/v1/logs" \
124+
-H 'Content-Type: application/json' \
125+
-H 'Content-Encoding: gzip' \
126+
--insecure \
127+
--data-binary @/tmp/otel-log3.json.gz
63128
```
64129
{% include copy.html %}
65130

131+
The document stored in OpenSearch contains the following information:
132+
133+
```json
134+
{
135+
...
136+
"hits": {
137+
"total": {
138+
"value": 1,
139+
"relation": "eq"
140+
},
141+
"max_score": 1,
142+
"hits": [
143+
{
144+
"_index": "otel-logs-otel-output",
145+
"_id": "l24NBpoBk9xzgdmMXFDm",
146+
"_score": 1,
147+
"_source": {
148+
"traceId": "",
149+
"instrumentationScope": {
150+
"name": "manual-gzip",
151+
"droppedAttributesCount": 0
152+
},
153+
"resource": {
154+
"attributes": {
155+
"service.name": "checkout",
156+
"service.version": "1.4.2"
157+
},
158+
"schemaUrl": "",
159+
"droppedAttributesCount": 0
160+
},
161+
"flags": 0,
162+
"severityNumber": 0,
163+
"body": "payment gateway timeout",
164+
"schemaUrl": "",
165+
"spanId": "",
166+
"severityText": "ERROR",
167+
"attributes": {
168+
"region": "eu-west-1",
169+
"latency_ms": 1234.5
170+
},
171+
"time": "2025-02-19T21:19:59Z",
172+
"droppedAttributesCount": 0,
173+
"observedTimestamp": "1970-01-01T00:00:00Z"
174+
}
175+
}
176+
]
177+
}
178+
}
179+
```
180+
66181
## Metrics
67182

68183
You can use the following metrics with the `otel_logs_source` source.

0 commit comments

Comments
 (0)