DEV Community

Cover image for Monitoring Nginx Ingress Controller with Prometheus & Grafana.
chrisedrego
chrisedrego

Posted on

Monitoring Nginx Ingress Controller with Prometheus & Grafana.

Simple Guide to Monitoring Nginx Ingress Controller

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***

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
Enter fullscreen mode Exit fullscreen mode

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/

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.



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.



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

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

Let's Graph it up: Grafana

Adding Prometheus DataSource in Grafana

Go ahead and add Prometheus as the data source in Grafana

Head over to Grafana Configuration > DataSource > Add Data Sources

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.

Here’s is the link to the awesome dashboard for Grafana. **9614**
NGINX Ingress controller dashboard for Grafana

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.

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

Top comments (1)

Collapse
 
myronix8 profile image
myr0n1x

Can I add scrape config in Kube Prometheus Stack to override Prometheus values?