Skip to content

Monitor Nginx applications running on Amazon EKS

Note

Since v2.x, NGINX based applications monitoring on EKS has been merged within the eks-monitoring module to allow visibility both on the cluster and the workloads, #59.

In addition to EKS infrastructure monitoring, the current example provides curated Grafana dashboards, Prometheus alerting and recording rules with multiple configuration options for NGINX based workloads on EKS.

Setup

1. Add NGINX metrics, dashboards and alerts

From the EKS cluster monitoring example's configuration, simply enable the NGINX pattern's flag.

module "eks_monitoring" {
   ...
   enable_nginx = true
}

You can further customize the NGINX pattern by providing nginx_config options.

2. Grafana API key

Make sure to refresh your temporary Grafana API key

export TF_VAR_managed_grafana_workspace_id=g-xxx
export TF_VAR_grafana_api_key=`aws grafana create-workspace-api-key --key-name "observability-accelerator-$(date +%s)" --key-role ADMIN --seconds-to-live 1200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`

Deploy

Simply run this command to deploy.

terraform apply

Note

To see the complete NGINX example, open the example on the repository

Visualization

  1. Grafana dashboards

Go to the Dashboards panel of your Grafana workspace. You will see a list of dashboards under the Observability Accelerator Dashboards

image

Open the NGINX dashboard and you will be able to view its visualization

image

  1. Amazon Managed Service for Prometheus rules and alerts

Open the Amazon Managed Service for Prometheus console and view the details of your workspace. Under the Rules management tab, you will find new rules deployed.

image

Note

To setup your alert receiver, with Amazon SNS, follow this documentation

Deploy an example application to visualize metrics

In this section we will deploy sample application and extract metrics using AWS OpenTelemetry collector

1. Add the helm incubator repo:

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

2. Enter the following command to create a new namespace:

kubectl create namespace nginx-ingress-sample

3. Enter the following commands to install NGINX:

helm install my-nginx ingress-nginx/ingress-nginx \
--namespace nginx-ingress-sample \
--set controller.metrics.enabled=true \
--set-string controller.metrics.service.annotations."prometheus\.io/port"="10254" \
--set-string controller.metrics.service.annotations."prometheus\.io/scrape"="true"

4. Set an EXTERNAL-IP variable to the value of the EXTERNAL-IP column in the row of the NGINX ingress controller.

EXTERNAL_IP=your-nginx-controller-external-ip

5. Start some sample NGINX traffic by entering the following command.

SAMPLE_TRAFFIC_NAMESPACE=nginx-sample-traffic
curl https://raw.githubusercontent.com/aws-observability/terraform-aws-observability-accelerator/main/examples/existing-cluster-nginx/sample_traffic/nginx-traffic-sample.yaml |
sed "s/{{external_ip}}/$EXTERNAL_IP/g" |
sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" |
kubectl apply -f -

6. Verify if the application is running

kubectl get pods -n nginx-ingress-sample

7. Visualize the Application's dashboard

Log back into your Managed Grafana Workspace and navigate to the dashboard side panel, click on Observability Accelerator Dashboards Folder and open the NGINX Dashboard.