OneAgent HAProxy plugin¶
Gathers HAProxy stats served by the load balancer as a csv. The full description of stats is available at https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#9
Configuration includes:
- credentials, if stats are guarded by HTTP basic-auth.
- url to stats page - ";csv" will be automatically appended if missing. If url is absolute, it will remain so, if it is relative, it will be joined with "http://localhost" prefix
An example HAProxy stats csv:
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,
haproxy-backend,server_behind_haproxy,0,0,0,1,,27,8180,41254,,0,,0,0,0,0,no check,1,1,0,,,,,,1,1,1,,27,,2,0,,2,,,,0,8,0,19,3,0,0,,,,0,0,,,,,351293,,,0,1,2,13,
haproxy-backend,BACKEND,0,0,0,1,100,21962,5579929,25660881,0,0,,0,0,0,0,UP,1,1,0,,0,2863759,0,,1,1,0,,27,,1,0,,2,,,,0,21940,0,22,0,0,,,,,0,0,0,0,0,0,78967,,,0,0,0,1,
haproxy-frontend,FRONTEND,,,1,3,1000,23283,5885422,27269302,0,0,3,,,,,OPEN,,,,,,,,,1,2,0,,,,0,1,0,3,,,,0,23257,0,25,0,0,,1,3,23283,,,0,0,0,0,,,,,,,,
stats,FRONTEND,,,0,0,2000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,0,0,0,0,,,,,,,,
The measurements are gathered following few rules:
- each measurement is associated with service dimension. This allows sending multiple values of the same metric (for example reqest rate) under the same key, just changing the dimension.
- rows where svname=BACKEND are ignored. In the example above "haproxy-backend,BACKEND" would be ignored
- rows where svname=FRONTEND are associated with service dimension set to the value of pxname. In the example above, this would apply to "haproxy-frontend,FRONTEND" and "stats,FRONTEND" rows
- rows where svname is neither BACKEND/FRONTEND are associated with service pxname-svname. In the example above, this would apply to "haproxy-backend,server_behind_haproxy" row setting the dimensions to {service: haproxy-backend-server_behind_haproxy}
- measurement keys specified in json mostly mirror the ones specified in HAProxy docs, with additional be_ or fe_ prefix to indicate whether they apply to frontends or backends
Limitations:
- HAProxy needs to be configured to serve statistics on a particular url, which might not be enabled by default.
- Multiple HAProxy worker processes running on the same configuration is not supported. Except for using HAProxy for terminating SSL traffic, such configuration is not recommended. It also breaks stats if not configured properly (each server having it's own unique url/port for stats) as by default, random HAProxy instance would answer the stats request without indicating which one it is.
- One instance of the plugin is created for each detected HAProxy process group instance. However current ruxit agent implementations merges all HAProxy processes into one process group, which means this effectively is a singleton plugin.
- SSL certificate verification is disabled.
-
class
ruxit_haproxy.HaProxyPlugin(**kwargs)[source]¶ Bases:
ruxit.api.base_plugin.BasePluginHAProxy plugin class. This plugin is stateful, however, the state is limited to some processing of received configuration, and no resources are acquired.
__init__ should not be overridden without a call to super.
Parameters: - config (Dict[str, str]) -- plugin configuration
- results_builder (ResultsBuilder) -- instance for this plugin,
- json_config -- parsed plugin.json contents,
- plugin_info (PluginInfo) -- json data of the plugin exposed in a more convenient way,
- associated_entity -- monitored entity associated with the plugin, if any (deprecated).
- activation_context -- activation context for the plugin,
- process_snapshot (ProcessSnapshot) -- latest available at method call,
- entity_resolver (EntityResolver) -- exposes additional methods for querying snapshot
- logger -- plugin specific logger for plugin development, set to None only in unit tests
-
initialize(**kwargs)[source]¶ Plugin initialization is limited to parsing configuration in order to construct url and auth parameters for later HTTP requests.
-
query(**kwargs)[source]¶ Tries to gather as much data as possible without raising errors - as long as a csv is received with enough information to extract proxy and server names, but some metrics missing - no errors are raised. This is to prevent unnecessary problems when different HAProxy versions provide different sets of metrics.
Raises: ruxit.api.exceptions.AuthException-- HAProxy responded with 401ruxit.api.exceptions.ConfigException-- connection and data parsing errors