Monitor Azure Container Service (AKS)

Monitoring your Kubernetes cluster and containers is critical, especially when running a production cluster, at scale, with multiple applications.

In this tutorial, you configure monitoring of your AKS cluster using the Containers solution for Log Analytics.

This tutorial, part seven of eight, covers the following tasks:

  • Configuring the container monitoring solution
  • Configuring the monitoring agents
  • Access monitoring information in the Azure portal

Before you begin

In previous tutorials, an application was packaged into container images, these images uploaded to Azure Container Registry, and a Kubernetes cluster created.

If you have not done these steps, and would like to follow along, return to Tutorial 1 – Create container images.

Configure the monitoring solution

In the Azure portal, select Create a resource and search for Container Monitoring Solution. Once located, select Create.

Add solution

Create a new OMS workspace, or select an existing one. The OMS Workspace form guides you through this process.

When creating the workspace, select Pin to dashboard for easy retrieval.

OMS Workspace

When done, select OK. Once validation has completed, select Create to create the container monitoring solution.

Once the workspace has been created, it is presented to you in the Azure portal.

Get Workspace settings

The Log analytics Workspace ID and Key are needed for configuring the solution agent on the Kubernetes nodes.

To retrieve these values, Select OMS Workspace from the container solutions left-hand menu. Select Advanced settings and take note of the WORKSPACE ID and the PRIMARY KEY.

Create Kubernetes secret

Store the OMS workspace settings in a Kubernetes secret named omsagent-secret using the kubectl create secret command. Update WORKSPACE_ID with your OMS workspace ID and WORKSPACE_KEY with the workspace key.

kubectl create secret generic omsagent-secret --from-literal=WSID=WORKSPACE_ID --from-literal=KEY=WORKSPACE_KEY

Configure monitoring agents

The following Kubernetes manifest file can be used to configure the container monitoring agents on a Kubernetes cluster. It creates a Kubernetes DaemonSet, which runs a single pod on each cluster node.

Save the following text to a file named oms-daemonset.yaml.

apiVersion: extensions/v1beta1
kind: DaemonSet
 name: omsagent
    app: omsagent
    agentVersion: 1.4.3-174
    dockerProviderVersion: 1.0.0-30
     - name: omsagent 
       image: "microsoft/oms"
       imagePullPolicy: Always
         privileged: true
       - containerPort: 25225
         protocol: TCP 
       - containerPort: 25224
         protocol: UDP
        - mountPath: /var/run/docker.sock
          name: docker-sock
        - mountPath: /var/log 
          name: host-log
        - mountPath: /etc/omsagent-secret
          name: omsagent-secret
          readOnly: true
        - mountPath: /var/lib/docker/containers 
          name: containerlog-path  
         - /bin/bash
         - -c
         - ps -ef | grep omsagent | grep -v "grep"
        initialDelaySeconds: 60
        periodSeconds: 60
   nodeSelector: linux    
   # Tolerate a NoSchedule taint on master that ACS Engine sets.
    - key: ""
      operator: "Equal"
      value: "true"
      effect: "NoSchedule"     
    - name: docker-sock 
       path: /var/run/docker.sock
    - name: host-log
       path: /var/log 
    - name: omsagent-secret
       secretName: omsagent-secret
    - name: containerlog-path
       path: /var/lib/docker/containers    

Create the DaemonSet with the following command:

kubectl create -f oms-daemonset.yaml

To see that the DaemonSet is created, run:

kubectl get daemonset

Output is similar to the following:

omsagent   3         3         3         3            3    8m

After the agents are running, it takes several minutes for OMS to ingest and process the data.

Access monitoring data

In the Azure portal, select the Log Analytics workspace that has been pinned to the portal dashboard. Click on the Container Monitoring Solution tile. Here you can find information about the AKS cluster and containers from the cluster.


See the Azure Log Analytics documentation for detailed guidance on querying and analyzing monitoring data.

Next steps

In this tutorial, you monitored your Kubernetes cluster with OMS. Tasks covered included:

  • Configuring the container monitoring solution
  • Configuring the monitoring agents
  • Access monitoring information in the Azure portal

Advance to the next tutorial to learn about upgrading Kubernetes to a new version.