Monitoring Nginx Ingress Controller with Prometheus & Grafana.
Tags: nginx, devops, monitoring, kubernetes
Published: 2021-05-29 08:11:12


![Simple Guide to Monitoring Nginx Ingress Controller](https://cdn-images-1.medium.com/max/2560/1*ORT3EJkt_g5y9ja5L19zjg.jpeg)

Before getting started we need to make sure that we have the following tools installed.

* Nginx Ingress Controller

* Prometheus

* Grafana.

Let’s install Nginx-Ingress Controller, Prometheus, Grafana with [***helm3](https://helm.sh/docs/intro/install/)***

    helm repo add nginx-stable [https://helm.nginx.com/stable](https://helm.nginx.com/stable)
    helm repo update

    helm install controller  nginx-stable/nginx-ingress 
    --set prometheus.create=true --set prometheus.port=9901

    helm install prometheus stable/prometheus
    helm install grafana stable/grafana

You can tweak the installation as per your needs, more details on this on [https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-helm/](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-helm/)

One extra work that is needed is that we need to expose a service that listens to the port that contains the Nginx-Ingress-Controllers Prometheus Metrics in our case it's *9901*.
{% gist https://gist.github.com/chrisedrego/3bc7498663f6959fbbb37692d6f52bf2.js %}
Once we have created the service we now can go ahead and add the endpoints for Prometheus to scrape. We need to make sure although Prometheus is present inside of the Kubernetes cluster so that in the case easily resolves the internal Domains of the Nginx-ingress controller.
{% gist https://gist.github.com/chrisedrego/57553155e43e1ab5e6d7d231553a732b.js %}
The next step is to use the above configuration as a Prometheus configuration. After which we can open Prometheus and head over the ***/targets*** page and verify if the ingress endpoints state is **UP**

![Verify if Prometheus URL](https://cdn-images-1.medium.com/max/2408/1*i9DLOQf2M7o7RhVwVi-Ijg.png)

To check what are the different types of metrics that Nginx Ingress Controller emits, we can head over to the Prometheus Dashboard and type in the console **n*ginx**. where *we receive a long list of different metrics that it emits.

![Nginx Ingress Controller Prometheus Metrics](https://cdn-images-1.medium.com/max/2144/1*tPzdgCl2tDgmr2LBiOCLVA.gif)

## Let's Graph it up: Grafana

### Adding Prometheus DataSource in Grafana

Go ahead and add Prometheus as the data source in [Grafana](https://grafana.com/)

*Head over to Grafana Configuration > DataSource > Add Data Sources*

![](https://cdn-images-1.medium.com/max/2592/1*x9zr3a48Xhj9V57vV4lbiQ.gif)

### Adding Dashboard in Grafana

Now, since we have added the Prometheus as a Datasource, we now need to added Dashboard for Nginx Ingress Controller. To make it less hassle-free there is already a Dashboard in place that gets everything set up with a few clicks.

![](https://cdn-images-1.medium.com/max/2956/1*f7w2sqVw5hRfH0mZ3KAgzw.gif)

Here’s is the link to the awesome dashboard for Grafana. [**9614](https://grafana.com/grafana/dashboards/9614)**
[**NGINX Ingress controller dashboard for Grafana**](https://grafana.com/grafana/dashboards/9614)

## Bingo! Here-we-go!

We have now successfully able to set up Prometheus to scrape the metrics and Graphana to show the eye-catchy visualization for Nginx-Ingress-Controller.

![](https://cdn-images-1.medium.com/max/2000/1*GFSurkpD_yN0ptxaW-7-0g.png)
> # if you found this article useful, feel free to click ❤️ Heart many times or share it with your friends and also follow me for more articles like these