Querying Python Metrics as customMetrics and custom attributes as customDimensions in Azure Application Insight
Azure Application Insights can be a collection point for Python Metrics that you can query and filter against. We can send Open Census metrics from anywhere in the world into Azure Application Insights. This lets us see our program metrics from any browser that can reach the Azure console. Application Monitor gives us a zero admin performance console.
OpenCensus metrics are recorded in Application Insights as customMetrics. Every metric sent is a row in Application Insights. The Azure OpenCensus Azure Exporter adds a standard set of attributes that appear in App Insights as CustomDimensions. We can add additional custom dimensions (attributes) to any metrics record sent Azure Application Insights.
All metrics are actually captured in a customMetrics table that we can query against.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.
Querying Metrics in the Application Insights Logs
- Log in to the Azure portal
- Open up the Application Insights resource that contains your data
- Scroll down the left-hand side until you find Monitoring / Logs
- Close the sample query pane on the right
- You should end up with a query screen that was behind the overlay pane.
- Type customMetrics into the query field and delete any extra terms that may have been added.
- Set the time window for your query in the dropdown on the right.
- Press on the Run button.
- You should see a list of individual events.
- Click on the Columns drop list and scroll until you see custom dimensions in the list item.
- Select that column.
- The column will appear in future queries.
References
Python Metrics and logs in Azure Applications Insights
- 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
Microsoft Guides
-
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
Python Data generator
-
https://github.com/freemansoft/speedtest-app-insights
Created 3/2021
- 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