Introduction

Nginx is a high-performance, open-source web server and reverse proxy that is widely used for load balancing, HTTP caching, and media streaming. Monitoring Nginx is crucial for tracking key performance metrics such as request rates, response times, error rates, active connections, and upstream health.

To monitor Nginx efficiently, we can use the OpenTelemetry Nginx Receiver, which collects key Nginx performance metrics and makes them available for analysis.

Steps to Configure

Step 1: Check for Existing ConfigMap

Run the following command to see if the opsramp-workload-metric-user-config ConfigMap already exists:

kubectl get configmap opsramp-workload-metric-user-config -n <agent-installed-namespace>

Step 2: Create a New ConfigMap (if not available)

If this is your first setup, create a workload-master ConfigMap. Use the following template and update it as per your workload requirements:

apiVersion: v1
kind: ConfigMap
metadata:
  name: opsramp-workload-metric-user-config
  namespace: opsramp-agent
data:
  workloads: |
    nginx:
    - name: nginx1
      maxConnsPerHost: 4
      idleConnTimeout: 5s
      disableKeepAlives: true
      http2ReadIdleTimeout: 1m
      collectionFrequency: 20m
      http2PingTimeout: 5s
      httpPath: nginx_status
      auth: none
      port: 80
      targetPodSelector: 
        matchLabels: 
          - key: app 
            operator: ==
            value: 
              - nginx
    - name: nginx-with-tls
      maxConnsPerHost: 4
      idleConnTimeout: 5s
      disableKeepAlives: true
      http2ReadIdleTimeout: 1m
      http2PingTimeout: 5s
      collectionFrequency: 10s
      httpPath: tls_stub_status
      auth: tls
      certFile:
        source: secret
        value: default/nginx-secret/tls.crt
      keyFile:
        source: secret
        value: default/nginx-secret/tls.key
      port: 443
      targetPodSelector: 
        matchLabels: 
          - key: app 
            operator: ==
            value: 
              - my-nginx-tls

Step 3: Apply the ConfigMap

kubectl apply -f <path-to-your-manifest-file>

Step 4: Verify in OpsRamp Portal

After a few minutes, check metrics in the OpsRamp Portal > Dashboards > Dashboard.

Step 5: Set Up Alerts and Availability Rules

Once metrics are visible, you can configure alerts and availability rules in the OpsRamp portal. Edit the relevant ConfigMaps to adjust workload or application-specific monitoring.

Supported Metrics

Supported metrics for this workload as provided by the Kubernetes 2.0 Agent.

MetricDescription
nginx_connections_acceptedTotal number of accepted connections in Nginx
nginx_connections_currentCurrent number of open connections in Nginx
nginx_connections_handledTotal number of handled connections in Nginx
nginx_requestsTotal number of requests processed by Nginx