Combine Azure Log Analytics with an AKS Cluster
Just like GKE (and unlike EKS), AKS comes with an integrated logging solution. All we have to do is enable one of the AKS addons. To be more precise, we’ll enable the
monitoring addon. As the name indicates, the addon not only fulfills the need to collect logs, but it also handles metrics. However, we are interested just in logs. I believe that nothing beats
Prometheus for metrics, especially since it integrates with
HorizontalPodAutoscaler. Still, you should explore AKS metrics as well and reach your own conclusion. For now, we’ll explore only the logging part of the addon.
az aks enable-addons \
-a monitoring \
-n devops25-cluster \
The output is a rather big JSON with all the information about the newly enabled
monitoring addon. There’s nothing exciting about it.
It’s important to note that we could have enabled the addon when we created the cluster by adding
-a monitoring argument to the
az aks create command.
If you’re curious about what we got, we can list the Deployments in the
kubectl -n kube-system get deployments
The output is as follows.
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
heapster 1 1 1 1 1m
kube-dns-v20 2 2 2 2 1h
kubernetes-dashboard 1 1 1 1 1h
metrics-server 1 1 1 1 1h
omsagent-rs 1 1 1 1 1m
tunnelfront 1 1 1 1 1h
The new addition is the
omsagent-rs Deployment that will ship the logs (and metrics) to Azure Log Analytics. If you
describe it, you’ll see that it is based on
microsoft/oms image. That makes it the first and the only time we switched from Fluentd to a different log shipping solution. We’ll use it simply because Azure recommends it.
Next, we need to wait for a few minutes until the logs are propagated to Log Analytics. This is the perfect moment for you to take a short break. Go fetch a cup of coffee.
Let’s open the Azure portal and see Log Analytics in action.
Please click the All services item from the left-hand menu, type log analytics in the Filter field, and click the Log Analytics item.