Azure Kubernetes Service is a fully managed Kubernetes service in Azure. It simplifies deploying and orchestrating containerized workload. It offers world class enterprise grade security, governance, deployment and monitoring capabilities. Use AKS to bring rapid development, deployment, scale and monitoring for your applications with confidence. Prometheus is a leading open source monitoring solution. In this blog post, we will explore how to integrate AKS with Prometheus for application monitoring needs.
Step 1 – Create AKS Cluster using the following steps.
Open Command Prompt and login to Azure subscription
Create resource group
az group create ––name=aksrg-monitoring ––location=westus
Create AKS cluster
az aks create ––resource-group aksrg-monitoring ––name aksclusterdemo-monitoring ––node-count 1 ––node-vm-size “Standard_DS2_v2” ––generate-ssh-keys
Enable Azure Monitor inside of the AKS cluster
az aks enable-addons -a monitoring -n aksclusterdemo-monitoring -g aksrg-monitoring
Download AKS Credentials to connect to the AKS Cluster
az aks get-credentials ––resource-group aksrg-monitoring ––name aksclusterdemo-monitoring
Step 2 – Deploy an app with Prometheus monitoring
In this step, we will deploy a sample application from Kubernetes-Hackfest which has Prometheus monitoring in place. The following piece of code creates a new Prometheus counter for the ‘requests_counter_total’
var requestsCounter = prometheus.NewCounter(
Help: “Total Requests Made.”,
Step 3 – Deploy Config Map to integrate with Azure Monitor.
Now we will integrate the logging by deploying configmap which can be found here – https://github.com/microsoft/OMS-docker/blob/ci_feature_prod/Kubernetes/container-azm-ms-agentconfig.yaml. We will set ‘Kubernetes Pod Monitoring’ to true.
kubectl apply -f container-azm-ms-agentconfig.yaml
Step 4 – Expose the sample app as service and set the Prometheus scraping to true.
As we can see, metrics from the sample app are sent to the Log Analytics service in Azure Monitor. You will continue to see great integration between the Azure Monitor and open source monitoring tools like Prometheus.