Displaying Python Metrics in Azure Application Insights
We can capture Python performance metrics in Azure Application Insights. This will let us see our program performance from anywhere that can reach the Azure console. I've used this to capture a variety of Python data manipulation and process timing without having to stand up any metrics databases or dashboards.
I wanted to plot basic internet performance information from data generated from two different machines in two different locations. The source code is on GitHub here freemansoft/speedtest-app-insights. That project runs speedtest.net measurements and then posts them to Azure Application Insights. We can create charts for any of the data gathered as part of this process.
Target Graphic
Execution pre-requisites
- You have an Azure login
- You have created an Azure Application Insights Application key https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource
- You have pushed data to Application Insights. I used https://github.com/freemansoft/speedtest-app-insights
Video walkthrough
Data Capture Notes
Our test program generates custom metrics which we can see in the Metrics section as aggregates and in the Logs section as individual events. Metrics, Tracing and Logs are all captured in the form of individual events in the Logs section of Application Insights.
Create a dashboard graphic that breaks data per machine
- Log into the Azure Console
- Navigate to Application Insights.
- Click on the Application Insights resource where we registered the data
- On the next page scroll down until you find Monitoring/Metrics and select that.
- Select the same resource name we selected before.
- Use the Metrics Namespace called Log-based metrics
- Select Apply Splitting button right next to add filter button.
- Select Cloud role instance. That name is bound to a property in every metric. It works even for apps not located in Azure or any cloud when using the Python library.
- There is a button at the top of the panel, right side of the screen that lets you pin this graphic to dashboard.
- You have the option of creating a new dashboard or adding to an existing one
References
- https://joe.blog.freemansoft.com/2022/11/querying-python-transactions-and-spans.html
- https://joe.blog.freemansoft.com/2021/03/querying-python-logs-azure-application.html
- https://joe.blog.freemansoft.com/2021/03/querying-python-metrics-custom-tags-as.html
- https://joe.blog.freemansoft.com/2021/03/displaying-python-metrics-in-azure.html
- https://joe.blog.freemansoft.com/2021/03/monitor-internet-broadband-service-with.html
- https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python
- https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource
- https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-azure
- https://github.com/freemansoft/speedtest-app-insights
Comments
Post a Comment