|
| 1 | +--- |
| 2 | +title: Export NGINX instance metrics |
| 3 | +weight: 500 |
| 4 | +toc: true |
| 5 | +nd-docs: DOCS-1882 |
| 6 | +--- |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +The F5 NGINX Agent now includes an embedded [OpenTelemetry](https://opentelemetry.io) collector, streamlining observability and metric collection for NGINX instances. By default, the NGINX Agent sends key metrics to the [NGINX One Console]({{< ref "/nginx-one/nginx-configs/metrics/review-metrics" >}}), providing quick visibility into server performance through pre-configured dashboards. |
| 11 | + |
| 12 | +With this feature, you can collect: |
| 13 | + |
| 14 | + - Metrics from NGINX Plus and NGINX Open Source |
| 15 | + - Host metrics such as CPU, memory, disk, and network activity from virtual machines (VMs) or containers |
| 16 | + |
| 17 | +For users requiring deeper integration with third-party observability tools, the NGINX Agent supports exporting additional metrics through the embedded OpenTelemetry collector. Tools such as Prometheus, Splunk, and other OpenTelemetry-compatible platforms can be configured to ingest these metrics, as detailed in the rest of this document. |
| 18 | + |
| 19 | +{{< call-out "note" >}} |
| 20 | +The OpenTelemetry exporter is enabled by default. Once a valid connection to the management plane is established, the NGINX Agent will automatically begin exporting metrics to the NGINX One Console. |
| 21 | +{{< /call-out >}} |
| 22 | + |
| 23 | +### Key benefits |
| 24 | + |
| 25 | +* Seamless Integration: No need to deploy an external OpenTelemetry Collector. All components are embedded within the Agent for streamlined observability. |
| 26 | +* Standardized Protocol: Support for OpenTelemetry standards ensures interoperability with a wide range of observability backends, including Prometheus, Splunk, and more. |
| 27 | + |
| 28 | +### Verify that metrics are exported |
| 29 | + |
| 30 | +You can validate that metrics are successfully exported by using the methods below: |
| 31 | + |
| 32 | +- **NGINX One dashboard** |
| 33 | + |
| 34 | + - When an instance has connected to NGINX One Console [See: Connect to NGINX One Console]({{< ref "/nginx-one/connect-instances/add-instance.md" >}}), you should see metrics showing on the NGINX One Console Dashboard. |
| 35 | + |
| 36 | +- **Agent logs** |
| 37 | + |
| 38 | + Check the OpenTelemetry Collector logs for confirmation of successful metric processing: |
| 39 | + |
| 40 | + 1. Open the file: `/var/log/nginx-agent/opentelemetry-collector-agent.log` |
| 41 | + 2. Look for the following logs: |
| 42 | + |
| 43 | + ```text |
| 44 | + Everything is ready. Begin running and processing data. |
| 45 | + ``` |
| 46 | +
|
| 47 | +### Custom OTel Configuration |
| 48 | +
|
| 49 | +NGINX Agent generates a default OpenTelemetry config (located at `/etc/nginx-agent/opentelemetry-collector-agent.yaml`) to send metrics to your management plane. An option is provided to |
| 50 | +bring your own [OpenTelemetry configs](https://opentelemetry.io/docs/collector/configuration/) which will be merged with the NGINX Agent default config. |
| 51 | +
|
| 52 | +The **order of the OpenTelemetry config files matters**: the last config in the list will take priority over others listed, if they have the same value configured. |
| 53 | +
|
| 54 | +{{<tabs name="custom-otel-configuration">}} |
| 55 | +
|
| 56 | +{{%tab name="VM"%}} |
| 57 | +
|
| 58 | +1. Edit the configuration file as root `vim /etc/nginx-agent/nginx-agent.conf` |
| 59 | +1. Add the collector property |
| 60 | +1. Save and restart the NGINX agent service `sudo systemctl restart nginx-agent` |
| 61 | +
|
| 62 | + ```yaml |
| 63 | + collector: |
| 64 | + additional_config_paths: |
| 65 | + - "/etc/nginx-agent/my_config.yaml" |
| 66 | + ``` |
| 67 | + |
| 68 | +{{%/tab%}} |
| 69 | + |
| 70 | +{{%tab name="Container"%}} |
| 71 | + |
| 72 | +1. Run the Docker container: |
| 73 | + |
| 74 | +Use the following command to run the NGINX Agent docker container. Replace the placeholder values (`YOUR_JWT_HERE`, `DPK`, `/path/to/my_config.yaml`, and `<version-tag>`) with the appropriate values for your environment: |
| 75 | + |
| 76 | + ```bash |
| 77 | + sudo docker run \ |
| 78 | + --env=NGINX_LICENSE_JWT="YOUR_JWT_HERE" \ |
| 79 | + --env=NGINX_AGENT_COMMAND_SERVER_PORT=443 \ |
| 80 | + --env=NGINX_AGENT_COMMAND_SERVER_HOST=agent.connect.nginx.com \ |
| 81 | + --env=NGINX_AGENT_COMMAND_AUTH_TOKEN="DPK" \ |
| 82 | + --env=NGINX_AGENT_COMMAND_TLS_SKIP_VERIFY=false \ |
| 83 | + --env=NGINX_AGENT_COLLECTOR_ADDITIONAL_CONFIG_PATHS="/etc/nginx-agent/my_config.yaml" \ |
| 84 | + --volume=/path/to/my_config.yaml:/etc/nginx-agent/my_config.yaml:ro \ |
| 85 | + --restart=always \ |
| 86 | + --runtime=runc \ |
| 87 | + -d private-registry.nginx.com/nginx-plus/agentv3:<version-tag> |
| 88 | + ``` |
| 89 | + |
| 90 | +{{%/tab%}} |
| 91 | + |
| 92 | +{{</tabs>}} |
| 93 | + |
| 94 | +#### Example usage |
| 95 | + |
| 96 | +{{< call-out "important" >}} NGINX Agent uses `/default` for naming its default processors, exporters and pipelines using the same naming in your own config might cause issues with sending metrics to your management plane {{< /call-out >}} |
| 97 | + |
| 98 | +#### Add Prometheus Exporter Configuration |
| 99 | + |
| 100 | +```yaml |
| 101 | +exporters: |
| 102 | + prometheus: |
| 103 | + endpoint: "127.0.0.1:5643" |
| 104 | + resource_to_telemetry_conversion: |
| 105 | + enabled: true |
| 106 | + namespace: test-space |
| 107 | + |
| 108 | +service: |
| 109 | + pipelines: |
| 110 | + metrics/prometheus-example-pipeline: |
| 111 | + receivers: |
| 112 | + - <nginxplus or nginx> # Use nginxplus for NGINX Plus or nginx for OSS |
| 113 | + processors: |
| 114 | + - resource/default |
| 115 | + exporters: |
| 116 | + - prometheus |
| 117 | +``` |
| 118 | +
|
| 119 | +
|
| 120 | +
|
| 121 | +#### Third-party OTel Collector |
| 122 | +
|
| 123 | +```yaml |
| 124 | +exporters: |
| 125 | + otlp/local-collector: |
| 126 | + endpoint: "my-local-collector.com:443" |
| 127 | + |
| 128 | +service: |
| 129 | + pipelines: |
| 130 | + metrics/otlp-example-pipeline: |
| 131 | + receivers: |
| 132 | + - nginxplus/nginx # Use nginxplus for NGINX Plus or nginx for OSS |
| 133 | + processors: |
| 134 | + - resource/default |
| 135 | + exporters: |
| 136 | + - otlp/local-collector |
| 137 | +``` |
| 138 | +
|
| 139 | +#### Add Debug Exporter |
| 140 | +
|
| 141 | +```yaml |
| 142 | +exporters: |
| 143 | + debug: |
| 144 | + verbosity: detailed |
| 145 | + sampling_initial: 5 |
| 146 | + sampling_thereafter: 200 |
| 147 | + |
| 148 | +service: |
| 149 | + pipelines: |
| 150 | + metrics/debug-example-pipeline: |
| 151 | + receivers: |
| 152 | + - nginxplus/nginx # Use nginxplus for NGINX Plus or nginx for OSS |
| 153 | + processors: |
| 154 | + - resource/default |
| 155 | + exporters: |
| 156 | + - debug |
| 157 | +``` |
| 158 | +
|
| 159 | +
|
| 160 | +
|
| 161 | +### Troubleshooting |
| 162 | +
|
| 163 | +To view the merged OpenTelemetry configuration, change the NGINX Agent log level to "debug" in `/etc/nginx-agent/nginx-agent.conf`: |
| 164 | + |
| 165 | +```yaml |
| 166 | + log: |
| 167 | + level: debug |
0 commit comments