生产环境中的host.docker.internal

问题描述 投票:0回答:1

我正在尝试为我的基于 java 的核心应用程序设置 opentelemetry。我正在使用 docker 启动 grafana、tempo、loki 和 prometheus 服务的容器。我想将指标导出到我已在 Grafana 中配置为数据源的 prometheus。在开发环境中,我使用了以下VM选项和prometheus配置文件更改。 虚拟机选项

-javaagent:C:\Users\A***.***\Downloads\opentelemetry-javaagent.jar -Dotel.exporter.otlp.endpoint=http://localhost:4317 -Dotel.service.name=auto-compensation-service -Dotel.exporter.otlp.insecure=true -Dotel.traces.exporter=otlp -Dotel.metrics.exporter=prometheus -Dotel.instrumentation.runtime-metrics.enabled=true -Dotel.exporter.prometheus.host=localhost -Dotel.exporter.prometheus.port=9464 
普罗米修斯配置: `全球: 刮擦间隔:30秒 scrap_timeout: 20s 评估间隔:15s

scrape_configs:
 - job_name: 'my-service'
   static_configs:
   - targets: [ 'host.docker.internal:9464']
   `

在开发环境中运行良好。现在我想在生产环境中测试一下。那么我应该使用什么主机名而不是“host.docker.internal”? 在生产设置中,grafana、tempo、loki 和 prometheus 容器由另一个应用程序启动,我希望 prometheus 服务器从我的应用程序中抓取指标。那么我必须在当前设置中进行哪些更改?

我在开发环境中进行了尝试,并且能够看到指标数据导出到 Prometheus 数据源。现在我想在生产环境上进行测试。那么我应该提供我机器的IP作为生产环境中的主机名吗?我的机器有一个动态 IP 地址,这会是一个问题吗?

请随时对此提出您的建议/意见/看法。 预先感谢您!!

docker prometheus production-environment open-telemetry
1个回答
0
投票

这取决于您的生产拓扑及其所使用的技术。一般来说,你的主机IP是什么并不重要,因为你不必使用动态IP进行路由,实际上你需要一个服务发现,但如果你想使用docker,你需要手动发现你的服务,你可以在你的主机之间定义一个网络接口应用程序和您的普罗米修斯并使用主机名进行连接 请记住您需要在图像上永久设置主机名

© www.soinside.com 2019 - 2024. All rights reserved.