Skip to content

Commit 5216f00

Browse files
authored
Add Grafana dashboard and installation steps (#1620)
Problem: As a user, I want to know how to easily install prometheus and grafana to visualize my NGF metrics. Solution: Add basic installation steps for both prometheus and grafana, and provide a sample dashboard (based on the nginx-prometheus-exporter dashboard)
1 parent 799ea76 commit 5216f00

File tree

4 files changed

+902
-45
lines changed

4 files changed

+902
-45
lines changed

site/content/how-to/monitoring/prometheus.md

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Prometheus Metrics"
3-
description: "Learn how to monitor your NGINX Gateway Fabric effectively. This guide provides easy steps for configuring and understanding key performance metrics using Prometheus."
3+
description: "This document describes how to monitor NGINX Gateway Fabric using Prometheus and Grafana. It explains installation and configuration, as well as what metrics are available."
44
weight: 100
55
toc: true
66
docs: "DOCS-1418"
@@ -11,16 +11,96 @@ docs: "DOCS-1418"
1111
## Overview
1212

1313

14-
NGINX Gateway Fabric metrics are displayed in [Prometheus](https://prometheus.io/) format, simplifying monitoring. You can track NGINX and controller-runtime metrics through a metrics server orchestrated by the controller-runtime package. These metrics are enabled by default and can be accessed on HTTP port `9113`.
15-
14+
NGINX Gateway Fabric metrics are displayed in [Prometheus](https://prometheus.io/) format. These metrics are served through a metrics server orchestrated by the controller-runtime package on HTTP port `9113`. When installed, Prometheus automatically scrapes this port and collects metrics. [Grafana](https://grafana.com/) can be used for rich visualization of these metrics.
1615

1716
{{<call-out "important" "Security note for metrics">}}
1817
Metrics are served over HTTP by default. Enabling HTTPS will secure the metrics endpoint with a self-signed certificate. When using HTTPS, adjust the Prometheus Pod scrape settings by adding the `insecure_skip_verify` flag to handle the self-signed certificate. For further details, refer to the [Prometheus documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#tls_config).
1918
{{</call-out>}}
2019

20+
## Installing Prometheus and Grafana
21+
22+
{{< note >}}These installations are for demonstration purposes and have not been tuned for a production environment.{{< /note >}}
23+
24+
### Prometheus
25+
26+
```shell
27+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
28+
helm repo update
29+
helm install prometheus prometheus-community/prometheus -n monitoring --create-namespace --set server.global.scrape_interval=15s
30+
```
31+
32+
Once running, you can access the Prometheus dashboard by using port-forwarding in the background:
33+
34+
```shell
35+
kubectl port-forward -n monitoring svc/prometheus-server 9090:80 &
36+
```
37+
38+
Visit [http://127.0.0.1:9090](http://127.0.0.1:9090) to view the dashboard.
39+
40+
### Grafana
41+
42+
43+
```shell
44+
helm repo add grafana https://grafana.github.io/helm-charts
45+
helm repo update
46+
helm install grafana grafana/grafana -n monitoring --create-namespace
47+
```
48+
49+
Once running, you can access the Grafana dashboard by using port-forwarding in the background:
50+
51+
```shell
52+
kubectl port-forward -n monitoring svc/grafana 3000:80 &
53+
```
54+
55+
Visit [http://127.0.0.1:3000](http://127.0.0.1:3000) to view the Grafana UI.
56+
57+
The username for login is `admin`. The password can be acquired by running:
58+
59+
```shell
60+
kubectl get secret -n monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
61+
```
62+
63+
#### Configuring Grafana
64+
65+
In the Grafana UI menu, go to `Connections` then `Data sources`. Add your Prometheus service (`http://prometheus-server.monitoring.svc`) as a data source.
66+
67+
Download the following sample dashboard and Import as a new Dashboard in the Grafana UI.
68+
69+
{{< download "grafana-dashboard.json" "ngf-grafana-dashboard.json" >}}
70+
71+
## Available metrics in NGINX Gateway Fabric
72+
73+
NGINX Gateway Fabric provides a variety of metrics for monitoring and analyzing performance. These metrics are categorized as follows:
74+
75+
### NGINX/NGINX Plus metrics
76+
77+
NGINX metrics cover specific NGINX operations such as the total number of accepted client connections. For a complete list of available NGINX/NGINX Plus metrics, refer to the [NGINX Prometheus Exporter developer docs](https://github.com/nginxinc/nginx-prometheus-exporter#exported-metrics).
78+
79+
These metrics use the `nginx_gateway_fabric` namespace and include the `class` label, indicating the NGINX Gateway class. For example, `nginx_gateway_fabric_connections_accepted{class="nginx"}`.
80+
81+
### NGINX Gateway Fabric metrics
82+
83+
Metrics specific to NGINX Gateway Fabric include:
84+
85+
- `nginx_reloads_total`: Counts successful NGINX reloads.
86+
- `nginx_reload_errors_total`: Counts NGINX reload failures.
87+
- `nginx_stale_config`: Indicates if NGINX Gateway Fabric couldn't update NGINX with the latest configuration, resulting in a stale version.
88+
- `nginx_last_reload_milliseconds`: Time in milliseconds for NGINX reloads.
89+
- `event_batch_processing_milliseconds`: Time in milliseconds to process batches of Kubernetes events.
90+
91+
All these metrics are under the `nginx_gateway_fabric` namespace and include a `class` label set to the Gateway class of NGINX Gateway Fabric. For example, `nginx_gateway_fabric_nginx_reloads_total{class="nginx"}`.
92+
93+
### Controller-runtime metrics
94+
95+
Provided by the [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) library, these metrics include:
96+
97+
- General resource usage like CPU and memory.
98+
- Go runtime metrics such as the number of Go routines, garbage collection duration, and Go version.
99+
- Controller-specific metrics, including reconciliation errors per controller, length of the reconcile queue, and reconciliation latency.
100+
21101
## How to change the default metrics configuration
22102

23-
Configuring NGINX Gateway Fabric for monitoring is straightforward. You can change metric settings using Helm or Kubernetes manifests, depending on your setup.
103+
You can configure monitoring metrics for NGINX Gateway Fabric using Helm or Manifests.
24104

25105
### Using Helm
26106

@@ -85,33 +165,3 @@ For enhanced security with HTTPS:
85165
prometheus.io/scheme: "https"
86166
<...>
87167
```
88-
89-
## Available metrics in NGINX Gateway Fabric
90-
91-
NGINX Gateway Fabric provides a variety of metrics to assist in monitoring and analyzing performance. These metrics are categorized as follows:
92-
93-
### NGINX/NGINX Plus metrics
94-
95-
NGINX metrics, essential for monitoring specific NGINX operations, include details like the total number of accepted client connections. For a complete list of available NGINX/NGINX Plus metrics, refer to the [NGINX Prometheus Exporter developer docs](https://github.com/nginxinc/nginx-prometheus-exporter#exported-metrics).
96-
97-
These metrics use the `nginx_gateway_fabric` namespace and include the `class` label, indicating the NGINX Gateway class. For example, `nginx_gateway_fabric_connections_accepted{class="nginx"}`.
98-
99-
### NGINX Gateway Fabric metrics
100-
101-
Metrics specific to the NGINX Gateway Fabric include:
102-
103-
- `nginx_reloads_total`: Counts successful NGINX reloads.
104-
- `nginx_reload_errors_total`: Counts NGINX reload failures.
105-
- `nginx_stale_config`: Indicates if NGINX Gateway Fabric couldn't update NGINX with the latest configuration, resulting in a stale version.
106-
- `nginx_last_reload_milliseconds`: Time in milliseconds for NGINX reloads.
107-
- `event_batch_processing_milliseconds`: Time in milliseconds to process batches of Kubernetes events.
108-
109-
All these metrics are under the `nginx_gateway_fabric` namespace and include a `class` label set to the Gateway class of NGINX Gateway Fabric. For example, `nginx_gateway_fabric_nginx_reloads_total{class="nginx"}`.
110-
111-
### Controller-runtime metrics
112-
113-
Provided by the [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) library, these metrics cover a range of aspects:
114-
115-
- General resource usage like CPU and memory.
116-
- Go runtime metrics such as the number of Go routines, garbage collection duration, and Go version.
117-
- Controller-specific metrics, including reconciliation errors per controller, length of the reconcile queue, and reconciliation latency.

site/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/nginxinc/nginx-gateway-fabric/site
22

33
go 1.21
44

5-
require github.com/nginxinc/nginx-hugo-theme v0.40.8 // indirect
5+
require github.com/nginxinc/nginx-hugo-theme v0.41.0 // indirect

site/go.sum

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
github.com/nginxinc/nginx-hugo-theme v0.35.0 h1:7XB2GMy6qeJgKEJy9wOS3SYKYpfvLW3/H+UHRPLM4FU=
2-
github.com/nginxinc/nginx-hugo-theme v0.35.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
3-
github.com/nginxinc/nginx-hugo-theme v0.39.0 h1:P1hOPpityVUOM5OyIpQZa1UJyuUunGSmz0oZh/GYSJM=
4-
github.com/nginxinc/nginx-hugo-theme v0.39.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
5-
github.com/nginxinc/nginx-hugo-theme v0.40.0 h1:YP0I0+bRKcJ5WEb1s/OWcnlcvNvIcKscagJkCzsa+Vs=
6-
github.com/nginxinc/nginx-hugo-theme v0.40.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
7-
github.com/nginxinc/nginx-hugo-theme v0.40.1 h1:1Q94uFYegNvjvwDV1py9VlYmh62AF1gh1oPGqjNmtis=
8-
github.com/nginxinc/nginx-hugo-theme v0.40.1/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
9-
github.com/nginxinc/nginx-hugo-theme v0.40.8 h1:VtoSAtf9k67tI2jzbLRo0oFBAMHZBUPRh/xV4MYullI=
10-
github.com/nginxinc/nginx-hugo-theme v0.40.8/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=
1+
github.com/nginxinc/nginx-hugo-theme v0.41.0 h1:uB9jC0Qk9i2CG63gScHxVHAEz1zyGoAdtY0Lcpkg1lI=
2+
github.com/nginxinc/nginx-hugo-theme v0.41.0/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=

0 commit comments

Comments
 (0)