# Agent and modules generated by the plugin

The plugin will create one agent for every HAProxy URL configured. The agent name is computed as an MD5 hash of the URL `netloc`, and the alias is set to that same `netloc` (for example, `192.168.0.10:8404`). Each agent includes the modules obtained by parsing the HAProxy CSV stats endpoint.

The `status` module is created **always** for every row, regardless of the monitor tokens, in order to alert on `DOWN`/`MAINT`/`STOP` states. The remaining numeric fields are included as `generic_data` (integer/decimal) or `generic_data_string` (string) modules, following the format `<pxname>_<svname>_<field>`.

The main fields available in the HAProxy CSV that generate modules are:

```bash
pxname: Proxy name (frontend/backend/listener).
svname: Service name (FRONTEND/BACKEND/server name).
qcur: Current queued requests.
qmax: Max queued requests.
scur: Current sessions.
smax: Max sessions.
slim: Configured session limit.
stot: Cumulative sessions.
bin: Bytes in.
bout: Bytes out.
dreq: Requests denied (security).
dresp: Responses denied (security).
ereq: Request errors.
econ: Connection errors to backend.
eresp: Response errors.
wretr: Connection retries.
wredis: Redispatches to another server.
status: Status (UP/DOWN/MAINT/STOP/...) — always monitored.
weight: Total weight / server weight.
act: Active servers (backend) / server active.
bck: Backup servers (backend) / server backup.
chkfail: Failed health checks.
chkdown: UP->DOWN transitions.
lastchg: Seconds since last UP<->DOWN transition.
downtime: Total downtime (seconds).
qlimit: Configured maxqueue for the server.
pid: Process ID.
iid: Unique proxy ID.
sid: Server ID (unique inside the proxy).
throttle: Current throttle percentage.
lbtot: Times the server was selected.
tracked: ID of proxy/server if tracking is enabled.
type: Type (0=frontend, 1=backend, 2=server, 3=socket).
rate: Sessions per second (last second).
rate_lim: Configured limit on new sessions/s.
rate_max: Max sessions per second.
check_status: Status of the last health check.
check_code: Layer 5-7 check code.
check_duration: Time in ms of the last health check.
hrsp_1xx: HTTP responses with 1xx code.
hrsp_2xx: HTTP responses with 2xx code.
hrsp_3xx: HTTP responses with 3xx code.
hrsp_4xx: HTTP responses with 4xx code.
hrsp_5xx: HTTP responses with 5xx code.
hrsp_other: HTTP responses with other codes.
hanafail: Failed health checks details.
req_rate: HTTP requests per second.
req_rate_max: Max HTTP requests per second.
req_tot: Total HTTP requests received.
cli_abrt: Data transfers aborted by the client.
srv_abrt: Data transfers aborted by the server.
comp_in: HTTP response bytes fed to the compressor.
comp_out: HTTP response bytes emitted by the compressor.
comp_byp: Bytes that bypassed the HTTP compressor.
comp_rsp: HTTP responses that were compressed.
lastsess: Seconds since the last session was assigned.
last_chk: Last health check contents/error.
last_agt: Last agent check contents/error.
qtime: Average queue time (ms) over the last 1024 requests.
ctime: Average connect time (ms) over the last 1024 requests.
rtime: Average response time (ms) over the last 1024 requests.
ttime: Average total session time (ms) over the last 1024 requests.
agent_status: Status of the last agent check.
agent_code: Numeric code reported by the agent.
agent_duration: Time in ms of the last agent check.
check_desc: Human-readable description of check_status.
agent_desc: Human-readable description of agent_status.
check_rise: Server's rise parameter used by checks.
check_fall: Server's fall parameter used by checks.
check_health: Server's health check value.
agent_rise: Agent's rise parameter.
agent_fall: Agent's fall parameter.
agent_health: Agent's health parameter.
addr: Address:port or unix socket.
cookie: Server's cookie value or backend's cookie name.
mode: Proxy mode (tcp, http, health, unknown).
algo: Load balancing algorithm.
conn_rate: Connections over the last elapsed second.
conn_rate_max: Highest known conn_rate.
conn_tot: Cumulative number of connections.
intercepted: Cumulative intercepted requests.
dcon: Requests denied by tcp-request connection rules.
dses: Requests denied by tcp-request session rules.
```

The `status` module is translated to a numeric value according to the following mapping: 5=UP, 4=OPEN, 3=NOLB, 2=MAINT, 1=STOP/STOPPING, 0=DOWN, which allows configuring alerts based on warning (2-4) and critical (0-2) thresholds.