There is severe shortage of tools for monitoring windows containers in general and specifically from inside running container OS. Steps outlined below will allow you to get basic OS health information (perfmon counters) as well as application level monitors from ASP.NET application.
Overview of the steps a below
- Create application insights resource in Azure
- Install and enable Application Insights status monitor into container
- Modify configuration file to add additional monitoring counters
Create application insights resource in Azure
New-AzureRmApplicationInsights -ResourceGroupName artisticcheese -Name appinsights -Location SouthCentralUS -Kind web
After resource is created find instrumentation key for it to supply to status monitor during runtime
PS Azure:\> Get-AzureRmApplicationInsights -Name appinsights -ResourceGroupName artisticcheese | select InstrumentationKey InstrumentationKey ------------------ 3c069cb6-fc1a-4bab-974c-0a4245ae7f1b
Install Application Insights Status Monitor inside container
Application Insights Status Monitor is distributed via WebPI installer which is dependent on UI part for installation which obviously is not going to work neither for server core installation or windows docker container. Below is extracted necessary parts to make it work in windows container (shall work in server core install as well)
Test application and integration
If you onboarded Azure AppInsights successfully you shall be able to see your live container under
Live Metric Stream. It will show your current vital status of your container like memory use/CPU and Request information in real time.
Make couple of hits to application to populate Application Insights data in Azure.
PS C:\> Invoke-WebRequest http://172.17.228.181/Service.svc/qod | select Content Content ------- Sustenance! Your health is always the best prescription.
If you go to any of the captured transactions now you shall be able to see breakdown of entire pipeline (including call to a backend dependency)
API which is being used (quote of the day) is limited to 10 hits an hour, continue hitting on web service 10 more time and you shall be start seeing failures in calls reflected inside AppInsights as well
Modify configuration file for adding additional monitoring data
You can add additonal perfmon data to be logged to application insights portal in addition to default set for ASP.NET. Open
ApplicationInsights.config file in root of your application and check commented part under <Add Type=”Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector”> tag
You can check how this works by checking repo (https://github.com/artisticcheese/artisticcheesecontainer/tree/master/appinsightscontainer). Image is also published to docker hub as artisticcheese/appinsights. Since I put my appinsights instrumentation key there it’s not going to help much but you can clone my repo and put your own key and see how it works.