metrics

The metrics directive allows the NGINX Proxy-Wasm module to define and record metrics during its operation.

Syntaxmetrics;
Defaultnone
Context
Argumentsnone

Description

The metrics directive is integral to the functionality of the NGINX Proxy-Wasm module, enabling it to define and handle metrics for monitoring performance and behavior of WebAssembly modules embedded within NGINX. It is designed to help developers track various performance indicators, such as request counts, latency, and error rates associated with the execution of WASM modules. By recording metrics, developers can gain insights into the performance characteristics of their application and potentially identify bottlenecks or issues that need attention.

The directive functions by allowing the configuration of various types of metrics, including counters and histograms. Each metric can be defined to track specific data points relevant to the execution of the WebAssembly modules. For instance, a counter might be used to increment with each incoming request that the WASM module processes, while a histogram could be utilized to capture latency distributions for those requests. This information can then be exported to monitoring tools for analytics and reporting.

Importantly, metrics can be recorded through the Proxy-Wasm interface, enabling the NGINX instance to communicate with external monitoring systems. This flexibility is essential for maintaining observability in complex architectures that utilize microservices and serverless functions. The absence of parameters or arguments in this directive reflects its straightforward purpose as a means to initiate metric tracking without additional configuration overhead.

Config Example

wasm {
    module my_filter /path/to/filter.wasm;
    metrics;
}

Ensure the metrics directive is placed correctly within the configuration to avoid context errors.

Metrics may not be recorded if there are issues with WASM module execution or if the metrics subsystem is not properly initialized.

← Back to all directives