[英]logs from two azure app service not dumping in a single app insight at the same time
I have 2 web apps
running using python flask
.我有
2 web apps
使用python flask
运行的 web 应用程序。
Created a single azure application insights
resource.创建了
single azure application insights
资源。
Logs from both the apps are not dumping into the same app insight at the time.这两个应用程序的日志当时并没有转储到同一个应用程序洞察力中。
There is a strange case I am seeing currently.我目前看到一个奇怪的案例。
Whichever web server starts recently, those app service logs are dumping into app insights.无论哪台 web 服务器最近启动,这些应用服务日志都会转储到应用洞察中。
But I need to have logs from both the apps in a single app insight.但是我需要在单个应用程序洞察力中同时获取这两个应用程序的日志。
I am using only logging.* feature.我只使用 logging.* 功能。 Not configured any telemetry or dependency tracking.
未配置任何遥测或依赖项跟踪。
Instrumentation Key
connection string has been configured properly in both the webapps. Instrumentation Key
连接字符串已在两个 webapps 中正确配置。 No issue with iKey
. iKey
没有问题。
If you have two or more services that send telemetry to the Same Application Insights resource , you're required to set Cloud Role Names to represent them properly on the Application Map.如果您有两个或更多服务将遥测数据发送到相同的 Application Insights 资源,则需要设置云角色名称以在应用程序 Map 上正确表示它们。
Set the Cloud Role Name and the Cloud Role Instance :-设置云角色名称和云角色实例:-
You might set the Cloud Role Name and the Cloud Role Instance via Resource attributes.您可以通过资源属性设置云角色名称和云角色实例。
This step updates Cloud Role Name and Cloud Role Instance from their default values to something that makes sense to your team.此步骤将 Cloud Role Name 和 Cloud Role Instance 从其默认值更新为对您的团队有意义的内容。 They'll appear on the Application Map as the name underneath a node.
它们将作为节点下方的名称出现在应用程序 Map 上。
Cloud Role Name uses service.namespace
and service.name
attributes, although it falls back to service.name
if service.namespace
isn't set.云角色名称使用
service.namespace
和service.name
属性,但如果未设置service.namespace
,它会回退到service.name
。
Cloud Role Instance uses the service.instance.id
attribute value.云角色实例使用
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
# -------------------------------------------
}
)
)
)
...
Note : Azure Monitor OpenTelemetry Exporter for Python applications is currently in preview and not yet released into general availability..注意:Azure Monitor OpenTelemetry Exporter for Python 应用程序目前处于预览阶段,尚未发布到一般可用性。
To become more familiar with Azure Monitor Application Insights and OpenTelemetry, see the Azure Monitor Example Application .要更加熟悉 Azure Monitor Application Insights 和 OpenTelemetry,请参阅Azure Monitor Example Application 。
Refer this link to Set up Azure Monitor for your Python application.请参阅此链接,为您的 Python 应用程序设置 Azure 监视器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.