Reference
dump stats-file
Available since
- HAProxy 3.0
- HAProxy Enterprise 3.0r1
Save the current state of the load balancer’s statistics counters to a file that you can use on the next service reload to populate the statistics counters with the existing values.
Description Jump to heading
You can persist your load balancer statistics counters after a reload by dumping the current values to a file. The HAProxy Stats page uses these counters. Once you have saved the state of the counters to a file, the load balancer will initialize its counters to those values so long as you have added the stats-file
configuration directive to the global
section of your configuration. Only proxy counters are included, that is, counters for frontends, backends, servers, and listeners.
Examples Jump to heading
To save and then to restore the statistics for your load balancer:
-
Assign GUIDs to each frontend, backend, listen, and server object in your configuration. For example, here is a simple configuration with one frontend that routes to one backend with one server. The frontend, backend, and server each have a globally unique identifier assigned:
haproxyfrontend mainguid 64aeebba-0911-483c-aa39-8f689cf3f657bind *:80default_backend appbackend appguid 9de9a5de-c3c2-47c4-b945-c4f61b7ece6abalance roundrobinserver app1 127.0.0.1:8080 check guid ae9194cc-f473-43de-ac21-43142340cf9chaproxyfrontend mainguid 64aeebba-0911-483c-aa39-8f689cf3f657bind *:80default_backend appbackend appguid 9de9a5de-c3c2-47c4-b945-c4f61b7ece6abalance roundrobinserver app1 127.0.0.1:8080 check guid ae9194cc-f473-43de-ac21-43142340cf9c -
Reload the load balancer to apply the configuration changes.
-
Call
dump stats-file
to create the stats file, redirecting the output to your desired location:nixecho "dump stats-file" | \sudo socat stdio tcp4-connect:127.0.0.1:9999 > <path/to/stats/file>nixecho "dump stats-file" | \sudo socat stdio tcp4-connect:127.0.0.1:9999 > <path/to/stats/file>The data in the file will capture the current state of the objects.
-
Add the
stats-file
configuration directive to yourglobal
section, specifying the path to your stats file location that the load balancer will reload:haproxyglobalstats-file <path/to/stats/file>haproxyglobalstats-file <path/to/stats/file> -
Reload the load balancer. It will initialize its statistics counters with the values from the file.
See also Jump to heading
Do you have any suggestions on how we can improve the content of this page?