Python Application Hosted On Docker(Azure Container Apps) Intergration with App Insights

Kanav Sharma 25 Reputation points
2025-01-10T15:10:17.9833333+00:00

I have hosted my python application on azure container app . I want to get metrics and logs in azure app insights. How can I achieve that?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,345 questions
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
511 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shireesha Eeraboina (Quadrant Resource LLC) 830 Reputation points Microsoft Vendor
    2025-01-16T05:23:13.6433333+00:00

    Hi @Kanav Sharma ,

    Thanks for posting your question in Microsoft Q&A, apologize for any inconvenience caused on this.

    To send logs from your xyz.log file inside a Docker container to Azure Application Insights, you can follow these steps:

    In the Azure portal, click on "Create a resource" and search for "Application Insights" and click "Create" and fill in the required details such as the resource name, subscription, resource group, and region then click "Review + create" and then "Create", Also ensure your Docker container is set up to send logs to Application Insights and You can use the opencensus-ext-azure package for Python applications, as mentioned earlier.

    • In the Azure portal, search for "Log Analytics workspaces" and create a new workspace and link your Application Insights resource to this workspace by navigating to your Application Insights resource, selecting "Properties", and then selecting the Log Analytics workspace you created then navigate to your Docker container's resource in the Azure portal under "Monitoring", select Diagnostic settings and click on "Add diagnostic setting" and choose the logs you want to send to Application Insights then select your Application Insights resource as the destination.
    • At last, navigate to your Application Insights resource and select "Logs" from the left-hand menu to query and view your logs, for your reference use the following query to view your logs:
       

    traces

    | where message contains "your log message"

    Also, you are trying to fetch live metrics from docker container/azure container app to App Insights so for these please refer the below documents:

    https://learn.microsoft.com/en-us/azure/container-apps/metrics

    https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-livedata-overview

    I hope the above provided information might help you, if you have any further queries, please feel free to reach out to us.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.