简体   繁体   中英

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 .
Created a single azure application insights resource.
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.

  • If webapp1 starts first and webapp2 starts second(after webapp1) -> app insights have logs of only webapps2
  • If webapp2 starts first and webapp1 starts second(after webapp2) -> app insights have logs of only webapps1.

But I need to have logs from both the apps in a single app insight.
I am using only logging.* feature. Not configured any telemetry or dependency tracking.

Instrumentation Key connection string has been configured properly in both the webapps. No issue with 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.

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. They'll appear on the Application Map as the name underneath a node.

Cloud Role Name uses service.namespace and service.name attributes, although it falls back to service.name if service.namespace isn't set.

Cloud Role Instance uses the service.instance.id attribute value.

... 
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..

To become more familiar with Azure Monitor Application Insights and OpenTelemetry, see the Azure Monitor Example Application .

Refer this link to Set up Azure Monitor for your Python application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM