Skip to content

Commit 947496b

Browse files
Updates Docker and Kubernetes to use EDOT Collector instead of APM Server
Signed-off-by: Adrian Cole <[email protected]>
1 parent c107fa3 commit 947496b

File tree

6 files changed

+256
-121
lines changed

6 files changed

+256
-121
lines changed

docker/README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Running your own Elastic Stack with Docker
22

3-
If you'd like to start Elastic locally, you can use the provided
4-
[docker-compose-elastic.yml](docker-compose-elastic.yml) file. This starts
5-
Elasticsearch, Kibana, and APM Server and only requires Docker installed.
3+
If you would like to start a local Elastic Stack with Docker, use
4+
[docker-compose-elastic.yml](docker-compose-elastic.yml).
5+
6+
This starts Elasticsearch, Kibana and Elastic Distribution of OpenTelemetry
7+
(EDOT) Collector.
68

79
Note: If you haven't checked out this repository, all you need is one file:
810
```bash
@@ -26,3 +28,21 @@ Clean up when finished, like this:
2628
```bash
2729
docker compose -f docker-compose-elastic.yml down
2830
```
31+
32+
## OpenTelemetry
33+
34+
### Metrics
35+
36+
If your application only sends logs or traces, you can skip this section.
37+
38+
EDOT Collector supports delta, not cumulative metrics. Applications that send
39+
OpenTelemetry metrics using the official OTEL SDK need to export this variable:
40+
```bash
41+
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
42+
```
43+
44+
Alternatively, you can use [EDOT language SDKs][edot-sdks] which set this by
45+
default.
46+
47+
---
48+
[edot-sdks]: https://github.com/elastic/opentelemetry?tab=readme-ov-file#edot-sdks--agents

docker/docker-compose-elastic.yml

+75-23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,69 @@
1+
# This is a Docker Compose file that runs a local Elastic Stack comprised of
2+
# Elasticsearch, Kibana and Elastic Distribution of OpenTelemetry (EDOT)
3+
# Collector.
14
name: elastic-stack
25

6+
configs:
7+
# This is the minimal yaml configuration needed to listen on all interfaces
8+
# for OTLP logs, metrics and traces, exporting to Elasticsearch.
9+
edot-collector-config:
10+
content: |
11+
receivers:
12+
otlp:
13+
protocols:
14+
grpc:
15+
endpoint: 0.0.0.0:4317
16+
http:
17+
endpoint: 0.0.0.0:4318
18+
19+
connectors:
20+
elasticapm:
21+
22+
processors:
23+
elastictrace:
24+
25+
exporters:
26+
elasticsearch:
27+
endpoint: http://elasticsearch:9200
28+
user: elastic
29+
password: elastic
30+
mapping:
31+
mode: otel
32+
logs_dynamic_index:
33+
enabled: true
34+
metrics_dynamic_index:
35+
enabled: true
36+
traces_dynamic_index:
37+
enabled: true
38+
flush:
39+
bytes: 1048576 # apm-server default instead of 5000000
40+
interval: 1s # apm-server default instead of 30s
41+
42+
service:
43+
pipelines:
44+
traces:
45+
receivers: [otlp]
46+
processors: [elastictrace]
47+
exporters: [elasticapm, elasticsearch]
48+
49+
metrics:
50+
receivers: [otlp]
51+
processors: []
52+
exporters: [elasticsearch]
53+
54+
metrics/aggregated:
55+
receivers: [elasticapm]
56+
processors: []
57+
exporters: [elasticsearch]
58+
59+
logs:
60+
receivers: [otlp]
61+
processors: []
62+
exporters: [elasticapm, elasticsearch]
63+
364
services:
465
elasticsearch:
5-
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
66+
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0
667
container_name: elasticsearch
768
ports:
869
- 9200:9200
@@ -38,7 +99,7 @@ services:
3899
depends_on:
39100
elasticsearch:
40101
condition: service_healthy
41-
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
102+
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0
42103
container_name: elasticsearch_settings
43104
restart: 'no'
44105
# gen-ai assistants in kibana save state in a way that requires system
@@ -53,7 +114,7 @@ services:
53114
'
54115
55116
kibana:
56-
image: docker.elastic.co/kibana/kibana:8.17.2
117+
image: docker.elastic.co/kibana/kibana:9.0.0
57118
container_name: kibana
58119
depends_on:
59120
elasticsearch_settings:
@@ -76,27 +137,18 @@ services:
76137
retries: 300
77138
interval: 1s
78139

79-
apm-server:
80-
image: docker.elastic.co/apm/apm-server:8.17.2
81-
container_name: apm-server
140+
otel-collector:
141+
image: docker.elastic.co/elastic-agent/elastic-otel-collector:9.0.0
142+
container_name: otel-collector
82143
depends_on:
83144
elasticsearch:
84145
condition: service_healthy
85-
command: >
86-
apm-server
87-
-E apm-server.kibana.enabled=true
88-
-E apm-server.kibana.host=http://kibana:5601
89-
-E apm-server.kibana.username=elastic
90-
-E apm-server.kibana.password=elastic
91-
-E output.elasticsearch.hosts=["http://elasticsearch:9200"]
92-
-E output.elasticsearch.username=elastic
93-
-E output.elasticsearch.password=elastic
94-
cap_add: ["CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID"]
95-
cap_drop: ["ALL"]
146+
command: [
147+
"--config=/etc/otelcol-contrib/config.yaml",
148+
]
149+
configs:
150+
- source: edot-collector-config
151+
target: /etc/otelcol-contrib/config.yaml
96152
ports:
97-
- 8200:8200
98-
healthcheck:
99-
test: ["CMD-SHELL", "bash -c 'echo -n > /dev/tcp/127.0.0.1/8200'"]
100-
retries: 300
101-
interval: 1s
102-
153+
- "4317:4317" # grpc
154+
- "4318:4318" # http

example-apps/chatbot-rag-app/README.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ Copy [env.example](env.example) to `.env` and fill in values noted inside.
2222
## Installing and connecting to Elasticsearch
2323

2424
There are a number of ways to install Elasticsearch. Cloud is best for most
25-
use-cases. We also have [docker-compose-elastic.yml][docker-compose-elastic],
26-
that starts Elasticsearch, Kibana, and APM Server on your laptop in one step.
25+
use-cases. We also have [docker-compose-elastic.yml][docker-compose],
26+
that starts Elasticsearch, Kibana, and Elastic Distribution of OpenTelemetry
27+
(EDOT) Collector on your laptop in one step.
2728

2829
Once you decided your approach, edit your `.env` file accordingly.
2930

@@ -84,8 +85,8 @@ copied to a file name `.env` and updated with `ELASTICSEARCH_URL` and
8485
For example, if you started your Elastic Stack with [k8s-manifest-elastic.yml][k8s-manifest-elastic],
8586
you would update these values:
8687
```
87-
ELASTICSEARCH_URL=http://elasticsearch:9200
88-
OTEL_EXPORTER_OTLP_ENDPOINT=http://apm-server:8200
88+
ELASTICSEARCH_URL=http://elasticsearch.default.svc:9200
89+
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.default.svc:4318
8990
```
9091

9192
Then, import your `.env` file as a configmap like this:
@@ -132,6 +133,7 @@ kubectl port-forward deployment.apps/chatbot-rag-app 4000:4000 &
132133
Clean up when finished, like this:
133134
```bash
134135
kubectl delete -f k8s-manifest.yml
136+
kubectl delete configmap chatbot-rag-app-env
135137
```
136138

137139
### Run with Python
@@ -197,16 +199,16 @@ prefix `python` with `opentelemetry-instrument` to enable OpenTelemetry.
197199
dotenv run -- opentelemetry-instrument python api/app.py
198200
```
199201

200-
[env.example](env.example) defaults to use Elastic APM server, started by
201-
[docker-compose-elastic.yml](../../docker). If you start your Elastic stack
202-
this way, you can access Kibana like this, authenticating with the username
202+
[env.example](env.example) defaults to use an OpenTelemetry Collector,
203+
specifically Elastic Distribution of OpenTelemetry (EDOT) Collector, if you
204+
started your Elastic Stack with [docker-compose-elastic.yml][docker-compose].
205+
If you did, you can access Kibana like this, authenticating with the username
203206
"elastic" and password "elastic":
204207

205208
http://localhost:5601/app/apm/traces?rangeFrom=now-15m&rangeTo=now
206209

207-
Under the scenes, chatbot-rag-app is automatically instrumented by the Elastic
208-
Distribution of OpenTelemetry (EDOT) Python. You can see more details about
209-
EDOT Python [here](https://github.com/elastic/elastic-otel-python).
210+
Under the scenes, chatbot-rag-app is automatically instrumented by EDOT Python.
211+
You can see more details about EDOT Python [here][edot-python].
210212

211213
OpenTelemetry support for LLM providers not included in EDOT Python are provided
212214
by the [Langtrace Python SDK](https://docs.langtrace.ai/sdk/python_sdk).
@@ -260,5 +262,6 @@ docker compose up --build --force-recreate
260262
---
261263
[loader-docs]: https://python.langchain.com/docs/how_to/#document-loaders
262264
[install-es]: https://www.elastic.co/search-labs/tutorials/install-elasticsearch
263-
[docker-compose-elastic]: ../../docker/docker-compose-elastic.yml
265+
[docker-compose]: ../../docker/docker-compose-elastic.yml
266+
[edot-python]: https://github.com/elastic/elastic-otel-python
264267
[k8s-manifest-elastic]: ../../k8s/k8s-manifest-elastic.yml

example-apps/chatbot-rag-app/env.example

+5-4
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ OTEL_SDK_DISABLED=true
7272
# Assign the service name that shows up in Kibana
7373
OTEL_SERVICE_NAME=chatbot-rag-app
7474

75-
# Default to send logs, traces and metrics to an Elastic APM server accessible
76-
# via localhost.
75+
# Default to send logs, traces and metrics to an OpenTelemetry collector,
76+
# accessible via localhost. For example, Elastic Distribution of OpenTelemetry
77+
# (EDOT) Collector.
7778
#
78-
# When running inside Kubernetes, set to http://elasticsearch.default.svc:9200
79+
# When running inside Kubernetes, set to http://otel-collector.default.svc:4318
7980
# or similar.
80-
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8200
81+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
8182
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
8283

8384
# Change to 'false' to hide prompt and completion content

k8s/README.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Running your own Elastic Stack with Kubernetes
22

3-
If you'd like to start Elastic with Kubernetes, you can use the provided
4-
[manifest-elastic.yml](manifest-elastic.yml) file. This starts
5-
Elasticsearch, Kibana, and APM Server in an existing Kubernetes cluster.
3+
If you would like to start a local Elastic Stack with Kubernetes, use
4+
[manifest-elastic.yml](manifest-elastic.yml).
5+
6+
This starts Elasticsearch, Kibana and Elastic Distribution of OpenTelemetry
7+
(EDOT) Collector.
68

79
Note: If you haven't checked out this repository, all you need is one file:
810
```bash
@@ -28,7 +30,7 @@ Elastic Stack version can take a long time due to image pulling.
2830
kubectl wait --for=condition=available --timeout=10m \
2931
deployment/elasticsearch \
3032
deployment/kibana \
31-
deployment/apm-server
33+
deployment/otel-collector
3234
```
3335

3436
Next, forward the kibana port:
@@ -45,3 +47,21 @@ Clean up when finished, like this:
4547
```bash
4648
kubectl delete -f k8s-manifest-elastic.yml
4749
```
50+
51+
## OpenTelemetry
52+
53+
### Metrics
54+
55+
If your application only sends logs or traces, you can skip this section.
56+
57+
EDOT Collector supports delta, not cumulative metrics. Applications that send
58+
OpenTelemetry metrics using the official OTEL SDK need to export this variable:
59+
```bash
60+
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
61+
```
62+
63+
Alternatively, you can use [EDOT language SDKs][edot-sdks] which set this by
64+
default.
65+
66+
---
67+
[edot-sdks]: https://github.com/elastic/opentelemetry?tab=readme-ov-file#edot-sdks--agents

0 commit comments

Comments
 (0)