I am trying to send Exceptions from my Python application running in Azure App service to the designated Azure Application Insights instance. I am using OpenCensus python library for this purpose. The basic logging and exception are successfully reaching to App Insight.
In addition to this i would like to know if there is a way where I can configure the Exception attributes like: problemId
or any other attributes explicitly to reflect specific value for easier alerting (like send email to specific group based on problemId).
Any suggestion/pointers would be super helpful
You can add custom properties to your log messages (not only exception, but all other log types too like trace, event etc.) in the extra keyword argument by using the
custom_dimensions
field. These properties appear as key-value pairs incustomDimensions
in Azure Monitor. Then you can query, see or configure alert based on that.For this feature to work, you need to pass a dictionary to the
custom_dimensions
field. If you pass arguments of any other type, the logger ignores them.NOTE: OpenCensus Python doesn't automatically track and send exception telemetry. They're sent through AzureLogHandler by using exceptions through the Python logging library. You can add custom properties just like with normal logging.
You can view customDimentions in Azure Portal like below (just example, not actual as per above code):
You can see the same in Kusto Query like below:
And you can query on those and configure alerts based on that (below image shows
traces
, for exceptions, it would beexceptions table
):