rtmp_stat

The 'rtmp_stat' directive generates RTMP streaming statistics in response to web requests.

Syntaxrtmp_stat path;
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The rtmp_stat directive is part of the NGINX RTMP module, providing a way for administrators to view streaming statistics through an HTTP endpoint. When enabled, it outputs key metrics related to active RTMP streams, including the number of connected clients, the total number of streams, and detailed statistics for each stream such as its name, number of bytes transmitted, and connection time. These statistics can be invaluable for monitoring server performance and stream activity in real time.

This directive can be utilized in the http, server, or location contexts. The basic functionality is to define a URL path through which RTMP statistics can be accessed. If multiple rtmp_stat directives are specified, they can be used to expose statistics at different endpoints. The statistics provided can be rendered in various formats, typically XML, allowing for easy integration with reporting tools or human-readable monitoring interfaces.

To facilitate access control, options such as restricting access based on IP addresses can be configured in tandem with rtmp_stat. This allows administrators to protect the statistic endpoint, ensuring only authorized users can retrieve sensitive stream data. Since statistics can reflect server load and resource usage, managing access to this information is critical for maintaining server security and performance.

Config Example

http {
    server {
        listen 8080;

        location /stat {
            # Enabling the RTMP statistics endpoint
            rtmp_stat all;
            # Allowing only localhost access to statistics
            allow 127.0.0.1;
            deny all;
        }
    }
}

Ensure you restrict access to the rtmp_stat URL to prevent unauthorized users from viewing streaming statistics.

Check your NGINX error logs if RTMP statistics are not displaying as expected, as misconfigurations can lead to silent failures.

The directive must be correctly placed in the configuration context to function (it must be under 'http', 'server', or 'location').

← Back to all directives