Delivering modern cloud-native applications with open source technologies on Azure Kubernetes Service
This section shows how to leverage Azure Monitor for Containers for gaining Monitoring and Logging insights into your AKS Cluster. If you recall from the AKS Cluster Creation section, the optional monitoring add-on was enabled which automatically integrated Azure Log Analytics with AKS. We will now explore what that add-on provides.
Setup Azure Monitor for Containers
If the monitoring add-on was not enabled, no worries, it can be added after the fact via the enable-addons command. If you are not sure you can check via the following command to see if the Pods are running. No out put means monitoring add-on is not running.
kubectl get ds omsagent --namespace=kube-system
To enable the add-on run the following command against your AKS Cluster.
az aks enable-addons -a monitoring -g $RGNAME -n $CLUSTERNAME
Enable Master Node Logs in AKS
Gaining Insights into Cluster Performance
HINT: Look at the Nodes Tab.
Getting Access to Container Logs
Running Custom Queries Against Logs
ContainerInventory
| distinct Image
| where Image contains "hackfest"
| render table
ContainerInventory
| project Computer, Name, Image, ImageTag, ContainerState, CreatedTime, StartedTime, FinishedTime
| render table
KubeEvents
| where not(isempty(Namespace))
| sort by TimeGenerated desc
| render table
ContainerImageInventory
| summarize AggregatedValue = count() by Image, ImageTag, Running
Master Node Logs
AzureDiagnostics
| distinct Category
AzureDiagnostics
| where Category == "kube-apiserver"
| project log_s
AzureDiagnostics
| where Category == "kube-apiserver"
| where log_s contains "pods/service-tracker-ui"
| project log_s
Application Insights
We enabled App Insights in our application in earlier labs. Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms.
Note: You may need to create traffic on your app by browsing the web site.
Click on “Application Dashboard” Browse the dashboard and the telemetry data.