You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a resource has errors relating to its configuration or relationship to other resources, they can likely be read in the status. The `ObservedGeneration` in the status should match the `ObservedGeneration` of the resource. Otherwise, this could mean that the resource hasn't been processed yet or that the status failed to update.
51
63
64
+
If no `Status` is written on the resource, further debug by checking if the referenced resources exists and belong to NGINX Gateway Fabric.
65
+
52
66
##### Events
53
67
54
68
Events created by NGINX Gateway Fabric or other Kubernetes components could indicate system or configuration issues. To see events:
55
69
56
70
```shell
57
-
kubectl get events [-n namespace]
71
+
kubectl get events -n nginx-gateway
58
72
```
59
73
60
74
For example, a warning event when the NginxGateway configuration CRD is deleted:
@@ -70,31 +84,33 @@ LAST SEEN TYPE REASON OBJECT
70
84
Getting shell access to containers allows developers and operators to view the environment of a running container, see its logs or diagnose any problems. To get shell access to the NGINX container, use `kubectl exec`:
Logs from the NGINX Gateway Fabric control plane and data plane can contain information that isn't available to status or events. These can include errors in processing or passing traffic.
1. To only see error logs for control plane and data plane containers:
93
109
94
-
For _nginx-gateway_ container, you can `grep` for the word `error` or change the log level to `error` by following steps in [Modify logging levels](#modify-logging-levels).
110
+
For _nginx-gateway_ container, you can `grep` for the word `error` or change the log level to `error` by following steps in [Modify logging levels](#modify-logging-levels). Once you have modified log levels, you can `grep` for the word `debug` to check debug logs for further investigation.
{"level":"error","ts":"2024-06-13T18:22:16Z","logger":"usageReporter","msg":"Usage reporting must be enabled when using NGINX Plus; redeploy with usage reporting enabled","error":"usage reporting not enabled","stacktrace":"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static.createUsageWarningJob.func1\n\tgithub.com/nginxinc/nginx-gateway-fabric/internal/mode/static/manager.go:616\nk8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1\n\tk8s.io/[email protected]/pkg/util/wait/backoff.go:259\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1\n\tk8s.io/[email protected]/pkg/util/wait/backoff.go:226\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil\n\tk8s.io/[email protected]/pkg/util/wait/backoff.go:227\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\tk8s.io/[email protected]/pkg/util/wait/backoff.go:204\nk8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext\n\tk8s.io/[email protected]/pkg/util/wait/backoff.go:259\ngithub.com/nginxinc/nginx-gateway-fabric/internal/framework/runnables.(*CronJob).Start\n\tgithub.com/nginxinc/nginx-gateway-fabric/internal/framework/runnables/cronjob.go:53\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\tsigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:226"}
106
122
```
107
123
108
-
For _nginx_ container:
124
+
For _nginx_ container you can `grep` for various [error](https://nginx.org/en/docs/ngx_core_module.html#error_log) log levels and they are all logged in brackets `[emerg]`:
1. NGINX access logs are files that record all requests processed by the NGINX server. These logs provide detailed information about each request, which can be useful for troubleshooting, and analyzing web traffic.
122
-
To view the access logs, get shell access to your NGINX container using the [steps](#get-shell-access-to-containers). The access logs are located in the file `/var/log/nginx/access.log` in the NGINX container.
138
+
To view the access logs, get shell access to your NGINX container using the [steps](#get-shell-access-to-nginx-container). The access logs are located in the file `/var/log/nginx/access.log` in the NGINX container.
139
+
Another method to check access logs is by reviewing the container logs for _nginx_ using:
You can see logs for a crashed or killed container by adding the `-p` flag to the above commands.
125
146
@@ -128,7 +149,7 @@ You can see logs for a crashed or killed container by adding the `-p` flag to th
128
149
To understand why the NGINX Gateway Fabric Pod has not started running or is not ready, the first step is to check the state of the Pod to get detailed information about the current status and events happening in the Pod. To do this, use `kubectl describe`:
129
150
130
151
```shell
131
-
kubectl describe pod <ngf-pod-name>[-n namespace]
152
+
kubectl describe pod <ngf-pod-name> -n nginx-gateway
132
153
```
133
154
134
155
The Pod description includes details about the image name, tags, current status, and environment variables. Please verify that these details match your setup and cross-check with the events to ensure everything is functioning as expected. For example, the Pod below has two containers that are running and the events reflect the same.
@@ -185,13 +206,14 @@ To debug NGINX Gateway Fabric, enable verbose logging by editing the `NginxGatew
185
206
NGINX reload errors can occur for various reasons, including syntax errors in configuration files, permission issues, and more. To determine if NGINX has failed to reload, check logs for your _nginx-gateway_ and _nginx_ containers.
186
207
You will see the following error in the _nginx-gateway_ logs `failed to reload NGINX:` followed by the reason for the failure. Similarly, error logs in _nginx_ container start with `emerg`. For example, `2024/06/12 14:25:11 [emerg] 12345#0: open() "/var/run/nginx.pid" failed (13: Permission denied)` shows a critical error, such as a permission problem preventing NGINX from accessing necessary files.
187
208
188
-
To debug why your reload has failed, start with verifying the syntax of your configuration files by opening a shell in the NGINX container following these [steps](#get-shell-access-to-containers) and running `nginx -T`. If there are errors in your configuration file, the reload will fail and specify why it has failed.
209
+
To debug why your reload has failed, start with verifying the syntax of your configuration files by opening a shell in the NGINX container following these [steps](#get-shell-access-to-nginx-container) and running `nginx -T`. If there are errors in your configuration file, the reload will fail and specify why it has failed.
189
210
190
211
### Understanding the generated NGINX config
191
212
192
-
Understanding the NGINX configuration is key for fixing issues because it shows how NGINX handles requests. This helps tweak settings to make sure NGINX behaves the way you want it to for your application. The configuration file is found at /etc/nginx/nginx.conf within your NGINX container. To understand the usage of NGINX directives in the configuration file, consult this list of [NGINX directives](https://nginx.org/en/docs/dirindex.html).
213
+
Understanding the NGINX configuration is key for fixing issues because it shows how NGINX handles requests. This helps tweak settings to make sure NGINX behaves the way you want it to for your application. To see your current configuration, you can open a shell in the _nginx_ container by following these [steps](#get-shell-access-to-nginx-container) and run `nginx -T`. To understand the usage of NGINX directives in the configuration file, consult this list of [NGINX directives](https://nginx.org/en/docs/dirindex.html).
193
214
194
-
In this section, we will see how the `nginx.conf` gets updated as we configure different services, deployments and routes with NGINX Gateway Fabric. In the configuration file, you'll often find several server blocks, each assigned to specific ports and server names. NGINX selects the appropriate server for a request and evaluates the URI against the location directives within that block. In cases, where no resources are defined, NGINX Gateway Fabric generates a basic configuration with a default server listening on port 80 for all requests and additional blocks to manage errors with status codes 500 or 502.
215
+
In this section, we will see how the configuration gets updated as we configure different Services, Deployments and HTTPRoutes with NGINX Gateway Fabric. In the configuration file, you'll often find several server blocks, each assigned to specific ports and server names. NGINX selects the appropriate server for a request and evaluates the URI against the location directives within that block.
216
+
When only a Gateway resource is defined, but no Services or HTTPRoutes are configured, NGINX generates a basic configuration. This includes a default server listening on the ports specified in the Gateway listeners, handling all incoming requests. Additionally, there are blocks to manage errors with status codes 500 or 502.
195
217
196
218
This is a default `server` block listening on port 80:
197
219
@@ -204,7 +226,7 @@ server {
204
226
}
205
227
```
206
228
207
-
Once routes with path matches and rules are defined, the nginx.conf is updated accordingly to determine which location block will manage incoming requests. To demonstrate how `nginx.conf` is changed, let's create some resources:
229
+
Once HTTPRoute with path matches and rules are defined, the nginx.conf is updated accordingly to determine which location block will manage incoming requests. To demonstrate how `nginx.conf` is changed, let's create some resources:
208
230
209
231
1. A Gateway with single listener on port 80. The hostname specified is `*.example.com`, so all incoming requests matching that wildcard is accepted by this Gateway.
210
232
2. A simple `coffee` application with hostname `cafe.example.com` and referenced to the Gateway we created.
@@ -326,6 +348,8 @@ Handling connection for 8080
326
348
</body>
327
349
```
328
350
351
+
**Warning** The configuration may change in future releases.
352
+
329
353
#### Metrics for Troubleshooting
330
354
331
355
Metrics can be useful to identify performance bottlenecks and pinpoint areas of high resource consumption within NGINX Gateway Fabric. To setup metrics collection, refer to this [guide]({{< relref "prometheus.md" >}}). The metrics dashboard will help you understand problems with the way NGINX Gateway Fabric is setup or potential issues that could show up with time.
@@ -334,6 +358,11 @@ For example, metrics `nginx_reloads_total` and `nginx_reload_errors_total` offer
334
358
335
359
In such situations, it's advisable to review the logs of both NGINX and NGINX Gateway containers for any potential error messages. Additionally, verify the configured resources to ensure they are in a valid state.
336
360
361
+
#### Access the N+ Dashboard
362
+
363
+
If you have NGINX Gateway Fabric installed with NGINX Plus, you can access the N+ dashboard at `http://localhost:8080/dashboard.html`.
364
+
Please note that, the port number i.e `8080` needs to be the set to the port number you have port-forward your NGINX Gateway Fabric Pod. For further [details]({{< relref "dashboard.md" >}})
0 commit comments