How can you log custom dimensions to Application Insights from your run or init functions in score.py for Azure Machine Learning inference?
While using the basic logger, all logs within init and run functions are lost. I attempted to address this issue by employing the AzureLogHandler. Although this enabled logging to Application Insights, I discovered that I need to instantiate the logger within both init and run functions for it to function correctly.
Additionally, how can I link my requestId to these logs in Application Insights to track which inference request this log is generated for?
P.S. I'm using python azure machine learning SDK V2 and a Kubernetes (AKS) backed online endpoint.
In Azure AutoML itself, there is logging. Below is a sample scoring script:
This logs the data in endpoint logs and Application Insights associated with your Azure ML workspace endpoint.
Here is the sample code:
Additionally, you can enable Inferencing data collection and Application Insights diagnostics while creating an endpoint, so you get more about endpoint logs into your application insight.
What you are currently using,
AzureLogHandler, is deprecated, but Microsoft supports it until retirement on September 30, 2024.Microsoft recommends the OpenTelemetry-based Python offering.
You can refer to this GitHub for more about it, and below is the sample execution.
Output:
For extra dimension you can add below code.
logger.info("INFO: Debug with properties", extra={"debug": "true"})