Docker 部署
前置条件
- Docker
- Docker Compose,版本需为 v2.0.0+
- Make(可选)
- 应用需占用 6 GB 内存
获取并运行演示程序
克隆演示仓库:
git clone https://github.com/open-telemetry/opentelemetry-demo.git
进入演示文件夹:
cd opentelemetry-demo/
开始演示1:
make start
docker compose up --force-recreate --remove-orphans --detach
(可选)启用基于 API 可观测性的测试1:
make run-tracetesting
docker compose -f docker-compose-tests.yml run traceBasedTests
验证 Web 商店和遥测数据
当镜像构建完成并容器启动后,你可以访问以下地址:
- Web 商店:http://localhost:8080/
- Grafana:http://localhost:8080/grafana/
- 负载生成器 UI:http://localhost:8080/loadgen/
- Jaeger UI:http://localhost:8080/jaeger/ui/
- Tracetest UI:http://localhost:11633/,仅在使用
make run-tracetesting
时可用 - Flagd 配置器 UI:http://localhost:8080/feature
修改演示的默认端口号
默认情况下,演示应用将为所有浏览器流量启动一个绑定在 8080 端口的代理服务。
如需更换端口号,请在启动演示前设置环境变量 ENVOY_PORT
。
例如,使用 8081 端口1:
ENVOY_PORT=8081 make start
ENVOY_PORT=8081 docker compose up --force-recreate --remove-orphans --detach
使用你自己的后端服务
你可能希望将 Web 商店作为演示应用,用于连接你已有的可观测性后端服务 (例如你已有的 Jaeger、Zipkin 实例,或你选择的其他厂商)。
OpenTelemetry Collector 可用于将遥测数据导出到多个后端。默认情况下,演示应用中的 Collector 会合并以下两个配置文件的内容:
otelcol-config.yml
otelcol-config-extras.yml
如需添加自己的后端服务,请使用编辑器打开文件 src/otel-collector/otelcol-config-extras.yml。
首先添加一个新的导出器。例如,如果你的后端支持通过 HTTP 的 OTLP 协议,添加如下内容:
exporters: otlphttp/example: endpoint: <your-endpoint-url>
然后重写要连接到你后端的遥测管道中的
exporters
配置:service: pipelines: traces: exporters: [spanmetrics, otlphttp/example]
在使用 Collector 合并 YAML 配置时,对象会被合并,但数组会被替换。
如果你重写了 traces
管道的 exporters
,必须确保数组中包含 spanmetrics
导出器。如果未包含该导出器,将导致错误
某些厂商的后端可能要求你添加额外的认证参数,请参考相应文档。部分后端需要使用不同的导出器,你可以在 opentelemetry-collector-contrib/exporter 找到这些导出器及其文档。
更新完 otelcol-config-extras.yml
后,通过运行 make start
开始演示。
稍等片刻后,你应能看到数据流入你的后端服务。
docker-compose
is deprecated. For details, see Migrate to Compose V2. ↩︎ ↩︎ ↩︎
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!