Deploy and Configure Prometheus and Grafana on AKS with Helm

Wei He
3 min readOct 10, 2022

Prometheus and Grafana are very popular tools to monitor running status of microservices. I am going to share my experience in this article how I deploy them on the Azure Kubernetes Service (AKS) via Helm Charts to monitor a special end point of a service. The Azure Container Registry (ACR) is also involved. It is just the most straightforward way without the advanced options like the Prometheus automatic discovery of scraped end points, Grafana sidecars and so on.

AKS and ACR

Certainly, I created an AKS on Azure at first.

Secondly, I created an ACR on Azure as the docker image repository. It is not a mandatory step. You can also use docker.io. In that case, you would just tag your images with “docker.io/” as the prefix instead of <acr-name>.azurecr.io for ACR

After creation of the ACR, I had to log in to get the authentication in PowerShell, on which I installed Azure modules (via az aks install-cli) firstly. The Azure PowerShell contains automatically the kubectl command.

A small Prometheus Adapter

Prometheus needs to scrape an end point of a service. I created a simple service, which has a GET end point /metrics that just responses with “get_response_statuscode 200” on request. I built the image with using the standard docker command, where the prometheus-adapter is the service name.

Then I created the Helm charts.

I left almost everything as default, except some customizations. The important parts are listed below:

Chart.yaml

values.yaml

Then I use Helm to deploy the service onto the AKS:

I chose the LoadBalancer for the networking, so the service would get a public IP, with which I could access the end point directly to test the response.

Prometheus

Prometheus has several standard charts. I selected the simple one.

Now I had to find a way to configure the scrape job. In Kubernetes, it is complicated to map the storage as usual. Fortunately, I found a position in value.yaml, which I copied from the repository to local. The following YAML snippet shows the modified part.

I just played the values onto the AKS. Note that is another values.yaml instead of the one of the prometheus-adapter:

The Prometheus server got an IP address after the deployment, so that I could access to the admin panel from the outside.

Grafana

Grafana is the final component to get the things to be visualized. I installed it via Helm chart, too.

I copied the values.yaml from the GitHub and changed the following lines:

Of course, I had to query the password for user admin in order to log in.

Now you can get a similar dashboard successfully.

As I mentioned above, this configuration is just a very primitive one with a simple simulation to what you would use the dockers directly on your server.

For more advanced configurations, I am studying yet.

--

--

Wei He

10 years software architect who likes designing and programming with Java and Angular, who can lead, participate and follow, who is always listening and open