![](/img/trans.png)
[英]Get logs from juypter notebook kernel in azure app service
[英]logs from two azure app service not dumping in a single app insight at the same time
我有2 web apps
使用python flask
运行的 web 应用程序。
创建了single azure application insights
资源。
这两个应用程序的日志当时并没有转储到同一个应用程序洞察力中。
我目前看到一个奇怪的案例。
无论哪台 web 服务器最近启动,这些应用服务日志都会转储到应用洞察中。
但是我需要在单个应用程序洞察力中同时获取这两个应用程序的日志。
我只使用 logging.* 功能。 未配置任何遥测或依赖项跟踪。
Instrumentation Key
连接字符串已在两个 webapps 中正确配置。 iKey
没有问题。
如果您有两个或更多服务将遥测数据发送到相同的 Application Insights 资源,则需要设置云角色名称以在应用程序 Map 上正确表示它们。
设置云角色名称和云角色实例:-
此步骤将 Cloud Role Name 和 Cloud Role Instance 从其默认值更新为对您的团队有意义的内容。 它们将作为节点下方的名称出现在应用程序 Map 上。
云角色名称使用service.namespace
和service.name
属性,但如果未设置service.namespace
,它会回退到service.name
。
云角色实例使用service.instance.id
属性值。
...
from opentelemetry.sdk.resources import SERVICE_NAME, SERVICE_NAMESPACE, SERVICE_INSTANCE_ID, Resource
trace.set_tracer_provider(
TracerProvider(
resource=Resource.create(
{
SERVICE_NAME: "my-helloworld-service",
# ----------------------------------------
# Setting role name and role instance
# ----------------------------------------
SERVICE_NAMESPACE: "my-namespace",
SERVICE_INSTANCE_ID: "my-instance",
# -------------------------------------------
# Done setting role name and role instance
# -------------------------------------------
}
)
)
)
...
注意:Azure Monitor OpenTelemetry Exporter for Python 应用程序目前处于预览阶段,尚未发布到一般可用性。
要更加熟悉 Azure Monitor Application Insights 和 OpenTelemetry,请参阅Azure Monitor Example Application 。
请参阅此链接,为您的 Python 应用程序设置 Azure 监视器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.