blob: 54f3732e36b4744a4ed8820a1eccc59bbae53d19 [file] [log] [blame]
Christopher Fauletf959d082019-02-07 15:38:42 +01001/*
2 * Promex is a Prometheus exporter for HAProxy
3 *
4 * It is highly inspired by the official Prometheus exporter.
5 * See: https://github.com/prometheus/haproxy_exporter
6 *
7 * Copyright 2019 Christopher Faulet <cfaulet@haproxy.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 */
15
16#include <common/cfgparse.h>
17#include <common/config.h>
18#include <common/buffer.h>
19#include <common/htx.h>
20#include <common/initcall.h>
21#include <common/memory.h>
22#include <common/mini-clist.h>
23
24#include <types/global.h>
25
26#include <proto/action.h>
27#include <proto/applet.h>
28#include <proto/backend.h>
29#include <proto/compression.h>
30#include <proto/frontend.h>
31#include <proto/listener.h>
32#include <proto/http_htx.h>
33#include <proto/pipe.h>
34#include <proto/proxy.h>
35#include <proto/sample.h>
36#include <proto/server.h>
37#include <proto/ssl_sock.h>
38#include <proto/stats.h>
39#include <proto/stream.h>
40#include <proto/stream_interface.h>
41#include <proto/task.h>
42
43/* Prometheus exporter applet states (appctx->st0) */
44enum {
45 PROMEX_ST_INIT = 0, /* initialized */
46 PROMEX_ST_HEAD, /* send headers before dump */
47 PROMEX_ST_DUMP, /* dumping stats */
48 PROMEX_ST_DONE, /* finished */
Christopher Faulet9744f7c2019-03-27 15:48:53 +010049 PROMEX_ST_END, /* treatment terminated */
Christopher Fauletf959d082019-02-07 15:38:42 +010050};
51
52/* Prometheus exporter dumper states (appctx->st1) */
53enum {
54 PROMEX_DUMPER_INIT = 0, /* initialized */
55 PROMEX_DUMPER_GLOBAL, /* dump metrics of globals */
56 PROMEX_DUMPER_FRONT, /* dump metrics of frontend proxies */
57 PROMEX_DUMPER_BACK, /* dump metrics of backend proxies */
58 PROMEX_DUMPER_LI, /* dump metrics of listeners */
59 PROMEX_DUMPER_SRV, /* dump metrics of servers */
60 PROMEX_DUMPER_DONE, /* finished */
61};
62
63/* Prometheus exporter flags (appctx->ctx.stats.flags) */
64#define PROMEX_FL_METRIC_HDR 0x00000001
65#define PROMEX_FL_INFO_METRIC 0x00000002
66#define PROMEX_FL_STATS_METRIC 0x00000004
Christopher Faulet32d634f2019-11-18 14:47:08 +010067#define PROMEX_FL_SCOPE_GLOBAL 0x00000008
68#define PROMEX_FL_SCOPE_FRONT 0x00000010
69#define PROMEX_FL_SCOPE_BACK 0x00000020
70#define PROMEX_FL_SCOPE_SERVER 0x00000040
Christopher Faulete48e9962019-11-19 14:18:24 +010071#define PROMEX_FL_NO_MAINT_SRV 0x00000080
Christopher Faulet32d634f2019-11-18 14:47:08 +010072
73#define PROMEX_FL_SCOPE_ALL (PROMEX_FL_SCOPE_GLOBAL|PROMEX_FL_SCOPE_FRONT|PROMEX_FL_SCOPE_BACK|PROMEX_FL_SCOPE_SERVER)
Christopher Fauletf959d082019-02-07 15:38:42 +010074
75/* The max length for metrics name. It is a hard limit but it should be
76 * enougth.
77 */
78#define PROMEX_MAX_NAME_LEN 128
79
80/* The expected max length for a metric dump, including its header lines. It is
81 * just a soft limit to avoid extra work. We don't try to dump a metric if less
82 * than this size is available in the HTX.
83 */
84#define PROMEX_MAX_METRIC_LENGTH 512
85
86/* Matrix used to dump global metrics. Each metric points to the next one to be
87 * processed or 0 to stop the dump. */
88const int promex_global_metrics[INF_TOTAL_FIELDS] = {
89 [INF_NAME] = INF_NBTHREAD,
90 [INF_VERSION] = 0,
91 [INF_RELEASE_DATE] = 0,
92 [INF_NBTHREAD] = INF_NBPROC,
93 [INF_NBPROC] = INF_PROCESS_NUM,
94 [INF_PROCESS_NUM] = INF_UPTIME_SEC,
95 [INF_PID] = 0,
96 [INF_UPTIME] = 0,
97 [INF_UPTIME_SEC] = INF_MEMMAX_MB,
98 [INF_MEMMAX_MB] = INF_POOL_ALLOC_MB,
99 [INF_POOL_ALLOC_MB] = INF_POOL_USED_MB,
100 [INF_POOL_USED_MB] = INF_POOL_FAILED,
101 [INF_POOL_FAILED] = INF_ULIMIT_N,
102 [INF_ULIMIT_N] = INF_MAXSOCK,
103 [INF_MAXSOCK] = INF_MAXCONN,
104 [INF_MAXCONN] = INF_HARD_MAXCONN,
105 [INF_HARD_MAXCONN] = INF_CURR_CONN,
106 [INF_CURR_CONN] = INF_CUM_CONN,
107 [INF_CUM_CONN] = INF_CUM_REQ,
108 [INF_CUM_REQ] = INF_MAX_SSL_CONNS,
109 [INF_MAX_SSL_CONNS] = INF_CURR_SSL_CONNS,
110 [INF_CURR_SSL_CONNS] = INF_CUM_SSL_CONNS,
111 [INF_CUM_SSL_CONNS] = INF_MAXPIPES,
112 [INF_MAXPIPES] = INF_PIPES_USED,
113 [INF_PIPES_USED] = INF_PIPES_FREE,
114 [INF_PIPES_FREE] = INF_CONN_RATE,
115 [INF_CONN_RATE] = INF_CONN_RATE_LIMIT,
116 [INF_CONN_RATE_LIMIT] = INF_MAX_CONN_RATE,
117 [INF_MAX_CONN_RATE] = INF_SESS_RATE,
118 [INF_SESS_RATE] = INF_SESS_RATE_LIMIT,
119 [INF_SESS_RATE_LIMIT] = INF_MAX_SESS_RATE,
120 [INF_MAX_SESS_RATE] = INF_SSL_RATE,
121 [INF_SSL_RATE] = INF_SSL_RATE_LIMIT,
122 [INF_SSL_RATE_LIMIT] = INF_MAX_SSL_RATE,
123 [INF_MAX_SSL_RATE] = INF_SSL_FRONTEND_KEY_RATE,
124 [INF_SSL_FRONTEND_KEY_RATE] = INF_SSL_FRONTEND_MAX_KEY_RATE,
125 [INF_SSL_FRONTEND_MAX_KEY_RATE] = INF_SSL_FRONTEND_SESSION_REUSE_PCT,
126 [INF_SSL_FRONTEND_SESSION_REUSE_PCT] = INF_SSL_BACKEND_KEY_RATE,
127 [INF_SSL_BACKEND_KEY_RATE] = INF_SSL_BACKEND_MAX_KEY_RATE,
128 [INF_SSL_BACKEND_MAX_KEY_RATE] = INF_SSL_CACHE_LOOKUPS,
129 [INF_SSL_CACHE_LOOKUPS] = INF_SSL_CACHE_MISSES,
130 [INF_SSL_CACHE_MISSES] = INF_COMPRESS_BPS_IN,
131 [INF_COMPRESS_BPS_IN] = INF_COMPRESS_BPS_OUT,
132 [INF_COMPRESS_BPS_OUT] = INF_COMPRESS_BPS_RATE_LIM,
133 [INF_COMPRESS_BPS_RATE_LIM] = INF_ZLIB_MEM_USAGE,
134 [INF_ZLIB_MEM_USAGE] = INF_MAX_ZLIB_MEM_USAGE,
135 [INF_MAX_ZLIB_MEM_USAGE] = INF_TASKS,
136 [INF_TASKS] = INF_RUN_QUEUE,
137 [INF_RUN_QUEUE] = INF_IDLE_PCT,
138 [INF_IDLE_PCT] = INF_STOPPING,
139 [INF_NODE] = 0,
140 [INF_DESCRIPTION] = 0,
141 [INF_STOPPING] = INF_JOBS,
142 [INF_JOBS] = INF_UNSTOPPABLE_JOBS,
143 [INF_UNSTOPPABLE_JOBS] = INF_LISTENERS,
144 [INF_LISTENERS] = INF_ACTIVE_PEERS,
145 [INF_ACTIVE_PEERS] = INF_CONNECTED_PEERS,
146 [INF_CONNECTED_PEERS] = INF_DROPPED_LOGS,
147 [INF_DROPPED_LOGS] = INF_BUSY_POLLING,
148 [INF_BUSY_POLLING] = 0,
149};
150
151/* Matrix used to dump frontend metrics. Each metric points to the next one to be
152 * processed or 0 to stop the dump. */
153const int promex_front_metrics[ST_F_TOTAL_FIELDS] = {
154 [ST_F_PXNAME] = ST_F_STATUS,
155 [ST_F_SVNAME] = 0,
156 [ST_F_QCUR] = 0,
157 [ST_F_QMAX] = 0,
158 [ST_F_SCUR] = ST_F_SMAX,
159 [ST_F_SMAX] = ST_F_SLIM,
160 [ST_F_SLIM] = ST_F_STOT,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200161 [ST_F_STOT] = ST_F_RATE_LIM,
Christopher Fauletf959d082019-02-07 15:38:42 +0100162 [ST_F_BIN] = ST_F_BOUT,
163 [ST_F_BOUT] = ST_F_DREQ,
164 [ST_F_DREQ] = ST_F_DRESP,
165 [ST_F_DRESP] = ST_F_EREQ,
166 [ST_F_EREQ] = ST_F_DCON,
167 [ST_F_ECON] = 0,
168 [ST_F_ERESP] = 0,
169 [ST_F_WRETR] = 0,
170 [ST_F_WREDIS] = 0,
171 [ST_F_STATUS] = ST_F_SCUR,
172 [ST_F_WEIGHT] = 0,
173 [ST_F_ACT] = 0,
174 [ST_F_BCK] = 0,
175 [ST_F_CHKFAIL] = 0,
176 [ST_F_CHKDOWN] = 0,
177 [ST_F_LASTCHG] = 0,
178 [ST_F_DOWNTIME] = 0,
179 [ST_F_QLIMIT] = 0,
180 [ST_F_PID] = 0,
181 [ST_F_IID] = 0,
182 [ST_F_SID] = 0,
183 [ST_F_THROTTLE] = 0,
184 [ST_F_LBTOT] = 0,
185 [ST_F_TRACKED] = 0,
186 [ST_F_TYPE] = 0,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200187 [ST_F_RATE] = 0,
Christopher Fauletf959d082019-02-07 15:38:42 +0100188 [ST_F_RATE_LIM] = ST_F_RATE_MAX,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200189 [ST_F_RATE_MAX] = ST_F_CONN_RATE_MAX,
Christopher Fauletf959d082019-02-07 15:38:42 +0100190 [ST_F_CHECK_STATUS] = 0,
191 [ST_F_CHECK_CODE] = 0,
192 [ST_F_CHECK_DURATION] = 0,
193 [ST_F_HRSP_1XX] = ST_F_HRSP_2XX,
194 [ST_F_HRSP_2XX] = ST_F_HRSP_3XX,
195 [ST_F_HRSP_3XX] = ST_F_HRSP_4XX,
196 [ST_F_HRSP_4XX] = ST_F_HRSP_5XX,
197 [ST_F_HRSP_5XX] = ST_F_HRSP_OTHER,
198 [ST_F_HRSP_OTHER] = ST_F_INTERCEPTED,
199 [ST_F_HANAFAIL] = 0,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200200 [ST_F_REQ_RATE] = 0,
Christopher Fauletf959d082019-02-07 15:38:42 +0100201 [ST_F_REQ_RATE_MAX] = ST_F_REQ_TOT,
202 [ST_F_REQ_TOT] = ST_F_HRSP_1XX,
203 [ST_F_CLI_ABRT] = 0,
204 [ST_F_SRV_ABRT] = 0,
205 [ST_F_COMP_IN] = ST_F_COMP_OUT,
206 [ST_F_COMP_OUT] = ST_F_COMP_BYP,
207 [ST_F_COMP_BYP] = ST_F_COMP_RSP,
208 [ST_F_COMP_RSP] = 0,
209 [ST_F_LASTSESS] = 0,
210 [ST_F_LAST_CHK] = 0,
211 [ST_F_LAST_AGT] = 0,
212 [ST_F_QTIME] = 0,
213 [ST_F_CTIME] = 0,
214 [ST_F_RTIME] = 0,
215 [ST_F_TTIME] = 0,
216 [ST_F_AGENT_STATUS] = 0,
217 [ST_F_AGENT_CODE] = 0,
218 [ST_F_AGENT_DURATION] = 0,
219 [ST_F_CHECK_DESC] = 0,
220 [ST_F_AGENT_DESC] = 0,
221 [ST_F_CHECK_RISE] = 0,
222 [ST_F_CHECK_FALL] = 0,
223 [ST_F_CHECK_HEALTH] = 0,
224 [ST_F_AGENT_RISE] = 0,
225 [ST_F_AGENT_FALL] = 0,
226 [ST_F_AGENT_HEALTH] = 0,
227 [ST_F_ADDR] = 0,
228 [ST_F_COOKIE] = 0,
229 [ST_F_MODE] = 0,
230 [ST_F_ALGO] = 0,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200231 [ST_F_CONN_RATE] = 0,
Christopher Fauletf959d082019-02-07 15:38:42 +0100232 [ST_F_CONN_RATE_MAX] = ST_F_CONN_TOT,
233 [ST_F_CONN_TOT] = ST_F_BIN,
234 [ST_F_INTERCEPTED] = ST_F_CACHE_LOOKUPS,
235 [ST_F_DCON] = ST_F_DSES,
236 [ST_F_DSES] = ST_F_WREW,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200237 [ST_F_WREW] = ST_F_REQ_RATE_MAX,
Christopher Fauletf959d082019-02-07 15:38:42 +0100238 [ST_F_CONNECT] = 0,
239 [ST_F_REUSE] = 0,
240 [ST_F_CACHE_LOOKUPS] = ST_F_CACHE_HITS,
241 [ST_F_CACHE_HITS] = ST_F_COMP_IN,
Christopher Fauletbd767f72019-11-08 15:24:32 +0100242 [ST_F_SRV_ICUR] = 0,
243 [ST_F_SRV_ILIM] = 0,
Christopher Faulet5df597a2019-11-08 15:05:31 +0100244 [ST_F_QT_MAX] = 0,
245 [ST_F_CT_MAX] = 0,
246 [ST_F_RT_MAX] = 0,
247 [ST_F_TT_MAX] = 0,
Christopher Fauletf959d082019-02-07 15:38:42 +0100248};
249
250/* Matrix used to dump backend metrics. Each metric points to the next one to be
251 * processed or 0 to stop the dump. */
252const int promex_back_metrics[ST_F_TOTAL_FIELDS] = {
253 [ST_F_PXNAME] = ST_F_STATUS,
254 [ST_F_SVNAME] = 0,
255 [ST_F_QCUR] = ST_F_QMAX,
256 [ST_F_QMAX] = ST_F_CONNECT,
257 [ST_F_SCUR] = ST_F_SMAX,
258 [ST_F_SMAX] = ST_F_SLIM,
259 [ST_F_SLIM] = ST_F_STOT,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200260 [ST_F_STOT] = ST_F_RATE_MAX,
Christopher Fauletf959d082019-02-07 15:38:42 +0100261 [ST_F_BIN] = ST_F_BOUT,
262 [ST_F_BOUT] = ST_F_QTIME,
263 [ST_F_DREQ] = ST_F_DRESP,
264 [ST_F_DRESP] = ST_F_ECON,
265 [ST_F_EREQ] = 0,
266 [ST_F_ECON] = ST_F_ERESP,
267 [ST_F_ERESP] = ST_F_WRETR,
268 [ST_F_WRETR] = ST_F_WREDIS,
269 [ST_F_WREDIS] = ST_F_WREW,
270 [ST_F_STATUS] = ST_F_SCUR,
271 [ST_F_WEIGHT] = ST_F_ACT,
272 [ST_F_ACT] = ST_F_BCK,
273 [ST_F_BCK] = ST_F_CHKDOWN,
274 [ST_F_CHKFAIL] = 0,
275 [ST_F_CHKDOWN] = ST_F_LASTCHG,
276 [ST_F_LASTCHG] = ST_F_DOWNTIME,
277 [ST_F_DOWNTIME] = ST_F_LBTOT,
278 [ST_F_QLIMIT] = 0,
279 [ST_F_PID] = 0,
280 [ST_F_IID] = 0,
281 [ST_F_SID] = 0,
282 [ST_F_THROTTLE] = 0,
283 [ST_F_LBTOT] = ST_F_REQ_TOT,
284 [ST_F_TRACKED] = 9,
285 [ST_F_TYPE] = 0,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200286 [ST_F_RATE] = 0,
Christopher Fauletf959d082019-02-07 15:38:42 +0100287 [ST_F_RATE_LIM] = 0,
288 [ST_F_RATE_MAX] = ST_F_LASTSESS,
289 [ST_F_CHECK_STATUS] = 0,
290 [ST_F_CHECK_CODE] = 0,
291 [ST_F_CHECK_DURATION] = 0,
292 [ST_F_HRSP_1XX] = ST_F_HRSP_2XX,
293 [ST_F_HRSP_2XX] = ST_F_HRSP_3XX,
294 [ST_F_HRSP_3XX] = ST_F_HRSP_4XX,
295 [ST_F_HRSP_4XX] = ST_F_HRSP_5XX,
296 [ST_F_HRSP_5XX] = ST_F_HRSP_OTHER,
297 [ST_F_HRSP_OTHER] = ST_F_CACHE_LOOKUPS,
298 [ST_F_HANAFAIL] = 0,
299 [ST_F_REQ_RATE] = 0,
300 [ST_F_REQ_RATE_MAX] = 0,
301 [ST_F_REQ_TOT] = ST_F_HRSP_1XX,
302 [ST_F_CLI_ABRT] = ST_F_SRV_ABRT,
303 [ST_F_SRV_ABRT] = ST_F_WEIGHT,
304 [ST_F_COMP_IN] = ST_F_COMP_OUT,
305 [ST_F_COMP_OUT] = ST_F_COMP_BYP,
306 [ST_F_COMP_BYP] = ST_F_COMP_RSP,
307 [ST_F_COMP_RSP] = 0,
308 [ST_F_LASTSESS] = ST_F_QCUR,
309 [ST_F_LAST_CHK] = 0,
310 [ST_F_LAST_AGT] = 0,
311 [ST_F_QTIME] = ST_F_CTIME,
312 [ST_F_CTIME] = ST_F_RTIME,
313 [ST_F_RTIME] = ST_F_TTIME,
Christopher Faulet5df597a2019-11-08 15:05:31 +0100314 [ST_F_TTIME] = ST_F_QT_MAX,
Christopher Fauletf959d082019-02-07 15:38:42 +0100315 [ST_F_AGENT_STATUS] = 0,
316 [ST_F_AGENT_CODE] = 0,
317 [ST_F_AGENT_DURATION] = 0,
318 [ST_F_CHECK_DESC] = 0,
319 [ST_F_AGENT_DESC] = 0,
320 [ST_F_CHECK_RISE] = 0,
321 [ST_F_CHECK_FALL] = 0,
322 [ST_F_CHECK_HEALTH] = 0,
323 [ST_F_AGENT_RISE] = 0,
324 [ST_F_AGENT_FALL] = 0,
325 [ST_F_AGENT_HEALTH] = 0,
326 [ST_F_ADDR] = 0,
327 [ST_F_COOKIE] = 0,
328 [ST_F_MODE] = 0,
329 [ST_F_ALGO] = 0,
330 [ST_F_CONN_RATE] = 0,
331 [ST_F_CONN_RATE_MAX] = 0,
332 [ST_F_CONN_TOT] = 0,
333 [ST_F_INTERCEPTED] = 0,
334 [ST_F_DCON] = 0,
335 [ST_F_DSES] = 0,
336 [ST_F_WREW] = ST_F_CLI_ABRT,
337 [ST_F_CONNECT] = ST_F_REUSE,
338 [ST_F_REUSE] = ST_F_BIN,
339 [ST_F_CACHE_LOOKUPS] = ST_F_CACHE_HITS,
340 [ST_F_CACHE_HITS] = ST_F_COMP_IN,
Christopher Fauletbd767f72019-11-08 15:24:32 +0100341 [ST_F_SRV_ICUR] = 0,
342 [ST_F_SRV_ILIM] = 0,
Christopher Faulet5df597a2019-11-08 15:05:31 +0100343 [ST_F_QT_MAX] = ST_F_CT_MAX,
344 [ST_F_CT_MAX] = ST_F_RT_MAX,
345 [ST_F_RT_MAX] = ST_F_TT_MAX,
346 [ST_F_TT_MAX] = ST_F_DREQ,
Christopher Fauletf959d082019-02-07 15:38:42 +0100347};
348
349/* Matrix used to dump server metrics. Each metric points to the next one to be
350 * processed or 0 to stop the dump. */
351const int promex_srv_metrics[ST_F_TOTAL_FIELDS] = {
352 [ST_F_PXNAME] = ST_F_STATUS,
353 [ST_F_SVNAME] = 0,
354 [ST_F_QCUR] = ST_F_QMAX,
355 [ST_F_QMAX] = ST_F_QLIMIT,
356 [ST_F_SCUR] = ST_F_SMAX,
357 [ST_F_SMAX] = ST_F_SLIM,
358 [ST_F_SLIM] = ST_F_STOT,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200359 [ST_F_STOT] = ST_F_RATE_MAX,
Christopher Fauletf959d082019-02-07 15:38:42 +0100360 [ST_F_BIN] = ST_F_BOUT,
361 [ST_F_BOUT] = ST_F_QTIME,
362 [ST_F_DREQ] = 0,
363 [ST_F_DRESP] = ST_F_ECON,
364 [ST_F_EREQ] = 0,
365 [ST_F_ECON] = ST_F_ERESP,
366 [ST_F_ERESP] = ST_F_WRETR,
367 [ST_F_WRETR] = ST_F_WREDIS,
368 [ST_F_WREDIS] = ST_F_WREW,
369 [ST_F_STATUS] = ST_F_SCUR,
Christopher Faulete019d182019-11-21 14:35:46 +0100370 [ST_F_WEIGHT] = ST_F_CHECK_STATUS,
Christopher Fauletf959d082019-02-07 15:38:42 +0100371 [ST_F_ACT] = 0,
372 [ST_F_BCK] = 0,
373 [ST_F_CHKFAIL] = ST_F_CHKDOWN,
374 [ST_F_CHKDOWN] = ST_F_DOWNTIME,
375 [ST_F_LASTCHG] = ST_F_THROTTLE,
376 [ST_F_DOWNTIME] = ST_F_LASTCHG,
377 [ST_F_QLIMIT] = ST_F_BIN,
378 [ST_F_PID] = 0,
379 [ST_F_IID] = 0,
380 [ST_F_SID] = 0,
381 [ST_F_THROTTLE] = ST_F_LBTOT,
382 [ST_F_LBTOT] = ST_F_HRSP_1XX,
383 [ST_F_TRACKED] = 0,
384 [ST_F_TYPE] = 0,
Christopher Fauletc58fc0d2019-04-18 10:10:49 +0200385 [ST_F_RATE] = 0,
Christopher Fauletf959d082019-02-07 15:38:42 +0100386 [ST_F_RATE_LIM] = 0,
387 [ST_F_RATE_MAX] = ST_F_LASTSESS,
Christopher Faulete019d182019-11-21 14:35:46 +0100388 [ST_F_CHECK_STATUS] = ST_F_CHECK_CODE,
Christopher Faulet4ab0efb2020-02-27 16:12:07 +0100389 [ST_F_CHECK_CODE] = ST_F_CHECK_DURATION,
390 [ST_F_CHECK_DURATION] = ST_F_CHKFAIL,
Christopher Fauletf959d082019-02-07 15:38:42 +0100391 [ST_F_HRSP_1XX] = ST_F_HRSP_2XX,
392 [ST_F_HRSP_2XX] = ST_F_HRSP_3XX,
393 [ST_F_HRSP_3XX] = ST_F_HRSP_4XX,
394 [ST_F_HRSP_4XX] = ST_F_HRSP_5XX,
395 [ST_F_HRSP_5XX] = ST_F_HRSP_OTHER,
Christopher Fauletbd767f72019-11-08 15:24:32 +0100396 [ST_F_HRSP_OTHER] = ST_F_SRV_ICUR,
Christopher Fauletf959d082019-02-07 15:38:42 +0100397 [ST_F_HANAFAIL] = 0,
398 [ST_F_REQ_RATE] = 0,
399 [ST_F_REQ_RATE_MAX] = 0,
400 [ST_F_REQ_TOT] = 0,
401 [ST_F_CLI_ABRT] = ST_F_SRV_ABRT,
402 [ST_F_SRV_ABRT] = ST_F_WEIGHT,
403 [ST_F_COMP_IN] = 0,
404 [ST_F_COMP_OUT] = 0,
405 [ST_F_COMP_BYP] = 0,
406 [ST_F_COMP_RSP] = 0,
407 [ST_F_LASTSESS] = ST_F_QCUR,
408 [ST_F_LAST_CHK] = 0,
409 [ST_F_LAST_AGT] = 0,
410 [ST_F_QTIME] = ST_F_CTIME,
411 [ST_F_CTIME] = ST_F_RTIME,
412 [ST_F_RTIME] = ST_F_TTIME,
Christopher Faulet5df597a2019-11-08 15:05:31 +0100413 [ST_F_TTIME] = ST_F_QT_MAX,
Christopher Fauletf959d082019-02-07 15:38:42 +0100414 [ST_F_AGENT_STATUS] = 0,
415 [ST_F_AGENT_CODE] = 0,
416 [ST_F_AGENT_DURATION] = 0,
417 [ST_F_CHECK_DESC] = 0,
418 [ST_F_AGENT_DESC] = 0,
419 [ST_F_CHECK_RISE] = 0,
420 [ST_F_CHECK_FALL] = 0,
421 [ST_F_CHECK_HEALTH] = 0,
422 [ST_F_AGENT_RISE] = 0,
423 [ST_F_AGENT_FALL] = 0,
424 [ST_F_AGENT_HEALTH] = 0,
425 [ST_F_ADDR] = 0,
426 [ST_F_COOKIE] = 0,
427 [ST_F_MODE] = 0,
428 [ST_F_ALGO] = 0,
429 [ST_F_CONN_RATE] = 0,
430 [ST_F_CONN_RATE_MAX] = 0,
431 [ST_F_CONN_TOT] = 0,
432 [ST_F_INTERCEPTED] = 0,
433 [ST_F_DCON] = 0,
434 [ST_F_DSES] = 0,
435 [ST_F_WREW] = ST_F_CLI_ABRT,
436 [ST_F_CONNECT] = ST_F_REUSE,
437 [ST_F_REUSE] = ST_F_DRESP,
438 [ST_F_CACHE_LOOKUPS] = 0,
439 [ST_F_CACHE_HITS] = 0,
Christopher Fauletbd767f72019-11-08 15:24:32 +0100440 [ST_F_SRV_ICUR] = ST_F_SRV_ILIM,
441 [ST_F_SRV_ILIM] = 0,
Christopher Faulet5df597a2019-11-08 15:05:31 +0100442 [ST_F_QT_MAX] = ST_F_CT_MAX,
443 [ST_F_CT_MAX] = ST_F_RT_MAX,
444 [ST_F_RT_MAX] = ST_F_TT_MAX,
445 [ST_F_TT_MAX] = ST_F_CONNECT,
Christopher Fauletf959d082019-02-07 15:38:42 +0100446};
447
448/* Name of all info fields */
449const struct ist promex_inf_metric_names[INF_TOTAL_FIELDS] = {
450 [INF_NAME] = IST("name"),
451 [INF_VERSION] = IST("version"),
452 [INF_RELEASE_DATE] = IST("release_date"),
453 [INF_NBTHREAD] = IST("nbthread"),
454 [INF_NBPROC] = IST("nbproc"),
455 [INF_PROCESS_NUM] = IST("relative_process_id"),
456 [INF_PID] = IST("pid"),
457 [INF_UPTIME] = IST("uptime"),
Christopher Faulet8c8e4b12019-04-18 10:15:15 +0200458 [INF_UPTIME_SEC] = IST("start_time_seconds"),
459 [INF_MEMMAX_MB] = IST("max_memory_bytes"),
460 [INF_POOL_ALLOC_MB] = IST("pool_allocated_bytes"),
461 [INF_POOL_USED_MB] = IST("pool_used_bytes"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100462 [INF_POOL_FAILED] = IST("pool_failures_total"),
463 [INF_ULIMIT_N] = IST("max_fds"),
464 [INF_MAXSOCK] = IST("max_sockets"),
465 [INF_MAXCONN] = IST("max_connections"),
466 [INF_HARD_MAXCONN] = IST("hard_max_connections"),
467 [INF_CURR_CONN] = IST("current_connections"),
468 [INF_CUM_CONN] = IST("connections_total"),
469 [INF_CUM_REQ] = IST("requests_total"),
470 [INF_MAX_SSL_CONNS] = IST("max_ssl_connections"),
471 [INF_CURR_SSL_CONNS] = IST("current_ssl_connections"),
472 [INF_CUM_SSL_CONNS] = IST("ssl_connections_total"),
473 [INF_MAXPIPES] = IST("max_pipes"),
474 [INF_PIPES_USED] = IST("pipes_used_total"),
475 [INF_PIPES_FREE] = IST("pipes_free_total"),
476 [INF_CONN_RATE] = IST("current_connection_rate"),
477 [INF_CONN_RATE_LIMIT] = IST("limit_connection_rate"),
478 [INF_MAX_CONN_RATE] = IST("max_connection_rate"),
479 [INF_SESS_RATE] = IST("current_session_rate"),
480 [INF_SESS_RATE_LIMIT] = IST("limit_session_rate"),
481 [INF_MAX_SESS_RATE] = IST("max_session_rate"),
482 [INF_SSL_RATE] = IST("current_ssl_rate"),
483 [INF_SSL_RATE_LIMIT] = IST("limit_ssl_rate"),
484 [INF_MAX_SSL_RATE] = IST("max_ssl_rate"),
485 [INF_SSL_FRONTEND_KEY_RATE] = IST("current_frontend_ssl_key_rate"),
486 [INF_SSL_FRONTEND_MAX_KEY_RATE] = IST("max_frontend_ssl_key_rate"),
487 [INF_SSL_FRONTEND_SESSION_REUSE_PCT] = IST("frontent_ssl_reuse"),
488 [INF_SSL_BACKEND_KEY_RATE] = IST("current_backend_ssl_key_rate"),
489 [INF_SSL_BACKEND_MAX_KEY_RATE] = IST("max_backend_ssl_key_rate"),
Christopher Faulet8c8e4b12019-04-18 10:15:15 +0200490 [INF_SSL_CACHE_LOOKUPS] = IST("ssl_cache_lookups_total"),
491 [INF_SSL_CACHE_MISSES] = IST("ssl_cache_misses_total"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100492 [INF_COMPRESS_BPS_IN] = IST("http_comp_bytes_in_total"),
493 [INF_COMPRESS_BPS_OUT] = IST("http_comp_bytes_out_total"),
494 [INF_COMPRESS_BPS_RATE_LIM] = IST("limit_http_comp"),
495 [INF_ZLIB_MEM_USAGE] = IST("current_zlib_memory"),
496 [INF_MAX_ZLIB_MEM_USAGE] = IST("max_zlib_memory"),
497 [INF_TASKS] = IST("current_tasks"),
498 [INF_RUN_QUEUE] = IST("current_run_queue"),
499 [INF_IDLE_PCT] = IST("idle_time_percent"),
500 [INF_NODE] = IST("node"),
501 [INF_DESCRIPTION] = IST("description"),
502 [INF_STOPPING] = IST("stopping"),
503 [INF_JOBS] = IST("jobs"),
504 [INF_UNSTOPPABLE_JOBS] = IST("unstoppable_jobs"),
505 [INF_LISTENERS] = IST("listeners"),
506 [INF_ACTIVE_PEERS] = IST("active_peers"),
507 [INF_CONNECTED_PEERS] = IST("connected_peers"),
508 [INF_DROPPED_LOGS] = IST("dropped_logs_total"),
509 [INF_BUSY_POLLING] = IST("busy_polling_enabled"),
510};
511
512/* Name of all stats fields */
513const struct ist promex_st_metric_names[ST_F_TOTAL_FIELDS] = {
514 [ST_F_PXNAME] = IST("proxy_name"),
515 [ST_F_SVNAME] = IST("service_name"),
516 [ST_F_QCUR] = IST("current_queue"),
517 [ST_F_QMAX] = IST("max_queue"),
518 [ST_F_SCUR] = IST("current_sessions"),
519 [ST_F_SMAX] = IST("max_sessions"),
520 [ST_F_SLIM] = IST("limit_sessions"),
521 [ST_F_STOT] = IST("sessions_total"),
522 [ST_F_BIN] = IST("bytes_in_total"),
523 [ST_F_BOUT] = IST("bytes_out_total"),
524 [ST_F_DREQ] = IST("requests_denied_total"),
525 [ST_F_DRESP] = IST("responses_denied_total"),
526 [ST_F_EREQ] = IST("request_errors_total"),
527 [ST_F_ECON] = IST("connection_errors_total"),
528 [ST_F_ERESP] = IST("response_errors_total"),
529 [ST_F_WRETR] = IST("retry_warnings_total"),
530 [ST_F_WREDIS] = IST("redispatch_warnings_total"),
531 [ST_F_STATUS] = IST("status"),
532 [ST_F_WEIGHT] = IST("weight"),
533 [ST_F_ACT] = IST("active_servers"),
534 [ST_F_BCK] = IST("backup_servers"),
535 [ST_F_CHKFAIL] = IST("check_failures_total"),
536 [ST_F_CHKDOWN] = IST("check_up_down_total"),
537 [ST_F_LASTCHG] = IST("check_last_change_seconds"),
538 [ST_F_DOWNTIME] = IST("downtime_seconds_total"),
539 [ST_F_QLIMIT] = IST("queue_limit"),
540 [ST_F_PID] = IST("pid"),
541 [ST_F_IID] = IST("proxy_id"),
542 [ST_F_SID] = IST("server_id"),
543 [ST_F_THROTTLE] = IST("current_throttle"),
544 [ST_F_LBTOT] = IST("loadbalanced_total"),
545 [ST_F_TRACKED] = IST("tracked"),
546 [ST_F_TYPE] = IST("type"),
547 [ST_F_RATE] = IST("current_session_rate"),
548 [ST_F_RATE_LIM] = IST("limit_session_rate"),
549 [ST_F_RATE_MAX] = IST("max_session_rate"),
550 [ST_F_CHECK_STATUS] = IST("check_status"),
551 [ST_F_CHECK_CODE] = IST("check_code"),
Christopher Faulet4ab0efb2020-02-27 16:12:07 +0100552 [ST_F_CHECK_DURATION] = IST("check_duration_seconds"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100553 [ST_F_HRSP_1XX] = IST("http_responses_total"),
554 [ST_F_HRSP_2XX] = IST("http_responses_total"),
555 [ST_F_HRSP_3XX] = IST("http_responses_total"),
556 [ST_F_HRSP_4XX] = IST("http_responses_total"),
557 [ST_F_HRSP_5XX] = IST("http_responses_total"),
558 [ST_F_HRSP_OTHER] = IST("http_responses_total"),
559 [ST_F_HANAFAIL] = IST("check_analyses_failures_total"),
560 [ST_F_REQ_RATE] = IST("http_requests_rate_current"),
561 [ST_F_REQ_RATE_MAX] = IST("http_requests_rate_max"),
562 [ST_F_REQ_TOT] = IST("http_requests_total"),
563 [ST_F_CLI_ABRT] = IST("client_aborts_total"),
564 [ST_F_SRV_ABRT] = IST("server_aborts_total"),
565 [ST_F_COMP_IN] = IST("http_comp_bytes_in_total"),
566 [ST_F_COMP_OUT] = IST("http_comp_bytes_out_total"),
567 [ST_F_COMP_BYP] = IST("http_comp_bytes_bypassed_total"),
568 [ST_F_COMP_RSP] = IST("http_comp_responses_total"),
569 [ST_F_LASTSESS] = IST("last_session_seconds"),
570 [ST_F_LAST_CHK] = IST("check_last_content"),
571 [ST_F_LAST_AGT] = IST("agentcheck_last_content"),
Christopher Faulet3388fd22019-11-08 15:12:29 +0100572 [ST_F_QTIME] = IST("queue_time_average_seconds"),
573 [ST_F_CTIME] = IST("connect_time_average_seconds"),
574 [ST_F_RTIME] = IST("response_time_average_seconds"),
575 [ST_F_TTIME] = IST("total_time_average_seconds"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100576 [ST_F_AGENT_STATUS] = IST("agentcheck_status"),
577 [ST_F_AGENT_CODE] = IST("agentcheck_code"),
578 [ST_F_AGENT_DURATION] = IST("agentcheck_duration_milliseconds"),
579 [ST_F_CHECK_DESC] = IST("check_description"),
580 [ST_F_AGENT_DESC] = IST("agentcheck_description"),
581 [ST_F_CHECK_RISE] = IST("check_rise"),
582 [ST_F_CHECK_FALL] = IST("check_fall"),
583 [ST_F_CHECK_HEALTH] = IST("check_value"),
584 [ST_F_AGENT_RISE] = IST("agentcheck_rise"),
585 [ST_F_AGENT_FALL] = IST("agentcheck_fall"),
586 [ST_F_AGENT_HEALTH] = IST("agentcheck_value"),
587 [ST_F_ADDR] = IST("address"),
588 [ST_F_COOKIE] = IST("cookie"),
589 [ST_F_MODE] = IST("mode"),
590 [ST_F_ALGO] = IST("loadbalance_algorithm"),
591 [ST_F_CONN_RATE] = IST("connections_rate_current"),
592 [ST_F_CONN_RATE_MAX] = IST("connections_rate_max"),
593 [ST_F_CONN_TOT] = IST("connections_total"),
594 [ST_F_INTERCEPTED] = IST("intercepted_requests_total"),
595 [ST_F_DCON] = IST("denied_connections_total"),
596 [ST_F_DSES] = IST("denied_sessions_total"),
597 [ST_F_WREW] = IST("failed_header_rewriting_total"),
598 [ST_F_CONNECT] = IST("connection_attempts_total"),
599 [ST_F_REUSE] = IST("connection_reuses_total"),
600 [ST_F_CACHE_LOOKUPS] = IST("http_cache_lookups_total"),
601 [ST_F_CACHE_HITS] = IST("http_cache_hits_total"),
Christopher Fauletbd767f72019-11-08 15:24:32 +0100602 [ST_F_SRV_ICUR] = IST("server_idle_connections_current"),
603 [ST_F_SRV_ILIM] = IST("server_idle_connections_limit"),
Christopher Faulet5df597a2019-11-08 15:05:31 +0100604 [ST_F_QT_MAX] = IST("max_queue_time_seconds"),
605 [ST_F_CT_MAX] = IST("max_connect_time_seconds"),
606 [ST_F_RT_MAX] = IST("max_response_time_seconds"),
607 [ST_F_TT_MAX] = IST("max_total_time_seconds"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100608};
609
610/* Description of all info fields */
611const struct ist promex_inf_metric_desc[INF_TOTAL_FIELDS] = {
612 [INF_NAME] = IST("Product name."),
613 [INF_VERSION] = IST("HAProxy version."),
614 [INF_RELEASE_DATE] = IST("HAProxy realease date."),
615 [INF_NBTHREAD] = IST("Configured number of threads."),
616 [INF_NBPROC] = IST("Configured number of processes."),
617 [INF_PROCESS_NUM] = IST("Relative process id, starting at 1."),
618 [INF_PID] = IST("HAProxy PID."),
619 [INF_UPTIME] = IST("Uptime in a human readable format."),
Christopher Faulet8c8e4b12019-04-18 10:15:15 +0200620 [INF_UPTIME_SEC] = IST("Start time in seconds."),
621 [INF_MEMMAX_MB] = IST("Per-process memory limit (in bytes); 0=unset."),
622 [INF_POOL_ALLOC_MB] = IST("Total amount of memory allocated in pools (in bytes)."),
623 [INF_POOL_USED_MB] = IST("Total amount of memory used in pools (in bytes)."),
Christopher Fauletf959d082019-02-07 15:38:42 +0100624 [INF_POOL_FAILED] = IST("Total number of failed pool allocations."),
625 [INF_ULIMIT_N] = IST("Maximum number of open file descriptors; 0=unset."),
626 [INF_MAXSOCK] = IST("Maximum numer of open sockets."),
627 [INF_MAXCONN] = IST("Maximum number of concurrent connections."),
628 [INF_HARD_MAXCONN] = IST("Initial Maximum number of concurrent connections."),
629 [INF_CURR_CONN] = IST("Number of active sessions."),
Christopher Faulet8c8e4b12019-04-18 10:15:15 +0200630 [INF_CUM_CONN] = IST("Total number of created sessions."),
Christopher Fauletf959d082019-02-07 15:38:42 +0100631 [INF_CUM_REQ] = IST("Total number of requests (TCP or HTTP)."),
632 [INF_MAX_SSL_CONNS] = IST("Configured maximum number of concurrent SSL connections."),
633 [INF_CURR_SSL_CONNS] = IST("Number of opened SSL connections."),
634 [INF_CUM_SSL_CONNS] = IST("Total number of opened SSL connections."),
635 [INF_MAXPIPES] = IST("Configured maximum number of pipes."),
636 [INF_PIPES_USED] = IST("Number of pipes in used."),
637 [INF_PIPES_FREE] = IST("Number of pipes unused."),
638 [INF_CONN_RATE] = IST("Current number of connections per second over last elapsed second."),
639 [INF_CONN_RATE_LIMIT] = IST("Configured maximum number of connections per second."),
640 [INF_MAX_CONN_RATE] = IST("Maximum observed number of connections per second."),
641 [INF_SESS_RATE] = IST("Current number of sessions per second over last elapsed second."),
642 [INF_SESS_RATE_LIMIT] = IST("Configured maximum number of sessions per second."),
643 [INF_MAX_SESS_RATE] = IST("Maximum observed number of sessions per second."),
644 [INF_SSL_RATE] = IST("Current number of SSL sessions per second over last elapsed second."),
645 [INF_SSL_RATE_LIMIT] = IST("Configured maximum number of SSL sessions per second."),
646 [INF_MAX_SSL_RATE] = IST("Maximum observed number of SSL sessions per second."),
647 [INF_SSL_FRONTEND_KEY_RATE] = IST("Current frontend SSL Key computation per second over last elapsed second."),
648 [INF_SSL_FRONTEND_MAX_KEY_RATE] = IST("Maximum observed frontend SSL Key computation per second."),
649 [INF_SSL_FRONTEND_SESSION_REUSE_PCT] = IST("SSL session reuse ratio (percent)."),
650 [INF_SSL_BACKEND_KEY_RATE] = IST("Current backend SSL Key computation per second over last elapsed second."),
651 [INF_SSL_BACKEND_MAX_KEY_RATE] = IST("Maximum observed backend SSL Key computation per second."),
652 [INF_SSL_CACHE_LOOKUPS] = IST("Total number of SSL session cache lookups."),
653 [INF_SSL_CACHE_MISSES] = IST("Total number of SSL session cache misses."),
654 [INF_COMPRESS_BPS_IN] = IST("Number of bytes per second over last elapsed second, before http compression."),
655 [INF_COMPRESS_BPS_OUT] = IST("Number of bytes per second over last elapsed second, after http compression."),
656 [INF_COMPRESS_BPS_RATE_LIM] = IST("Configured maximum input compression rate in bytes."),
657 [INF_ZLIB_MEM_USAGE] = IST("Current memory used for zlib in bytes."),
658 [INF_MAX_ZLIB_MEM_USAGE] = IST("Configured maximum amount of memory for zlib in bytes."),
659 [INF_TASKS] = IST("Current number of tasks."),
660 [INF_RUN_QUEUE] = IST("Current number of tasks in the run-queue."),
661 [INF_IDLE_PCT] = IST("Idle to total ratio over last sample (percent)."),
662 [INF_NODE] = IST("Node name."),
663 [INF_DESCRIPTION] = IST("Node description."),
664 [INF_STOPPING] = IST("Non zero means stopping in progress."),
665 [INF_JOBS] = IST("Current number of active jobs (listeners, sessions, open devices)."),
666 [INF_UNSTOPPABLE_JOBS] = IST("Current number of active jobs that can't be stopped during a soft stop."),
667 [INF_LISTENERS] = IST("Current number of active listeners."),
668 [INF_ACTIVE_PEERS] = IST("Current number of active peers."),
669 [INF_CONNECTED_PEERS] = IST("Current number of connected peers."),
670 [INF_DROPPED_LOGS] = IST("Total number of dropped logs."),
671 [INF_BUSY_POLLING] = IST("Non zero if the busy polling is enabled."),
672};
673
674/* Description of all stats fields */
675const struct ist promex_st_metric_desc[ST_F_TOTAL_FIELDS] = {
676 [ST_F_PXNAME] = IST("The proxy name."),
677 [ST_F_SVNAME] = IST("The service name (FRONTEND for frontend, BACKEND for backend, any name for server/listener)."),
678 [ST_F_QCUR] = IST("Current number of queued requests."),
679 [ST_F_QMAX] = IST("Maximum observed number of queued requests."),
680 [ST_F_SCUR] = IST("Current number of active sessions."),
681 [ST_F_SMAX] = IST("Maximum observed number of active sessions."),
682 [ST_F_SLIM] = IST("Configured session limit."),
683 [ST_F_STOT] = IST("Total number of sessions."),
684 [ST_F_BIN] = IST("Current total of incoming bytes."),
685 [ST_F_BOUT] = IST("Current total of outgoing bytes."),
686 [ST_F_DREQ] = IST("Total number of denied requests."),
687 [ST_F_DRESP] = IST("Total number of denied responses."),
688 [ST_F_EREQ] = IST("Total number of request errors."),
689 [ST_F_ECON] = IST("Total number of connection errors."),
690 [ST_F_ERESP] = IST("Total number of response errors."),
691 [ST_F_WRETR] = IST("Total number of retry warnings."),
692 [ST_F_WREDIS] = IST("Total number of redispatch warnings."),
Christopher Faulet8e40fa22019-09-06 16:10:19 +0200693 [ST_F_STATUS] = IST("Current status of the service (frontend: 0=STOP, 1=UP, 2=FULL - backend: 0=DOWN, 1=UP - server: 0=DOWN, 1=UP, 2=MAINT, 3=DRAIN, 4=NOLB)."),
Christopher Fauletf959d082019-02-07 15:38:42 +0100694 [ST_F_WEIGHT] = IST("Service weight."),
695 [ST_F_ACT] = IST("Current number of active servers."),
696 [ST_F_BCK] = IST("Current number of backup servers."),
697 [ST_F_CHKFAIL] = IST("Total number of failed check (Only counts checks failed when the server is up)."),
698 [ST_F_CHKDOWN] = IST("Total number of UP->DOWN transitions."),
699 [ST_F_LASTCHG] = IST("Number of seconds since the last UP<->DOWN transition."),
700 [ST_F_DOWNTIME] = IST("Total downtime (in seconds) for the service."),
701 [ST_F_QLIMIT] = IST("Configured maxqueue for the server (0 meaning no limit)."),
702 [ST_F_PID] = IST("Process id (0 for first instance, 1 for second, ...)"),
703 [ST_F_IID] = IST("Unique proxy id."),
704 [ST_F_SID] = IST("Server id (unique inside a proxy)."),
705 [ST_F_THROTTLE] = IST("Current throttle percentage for the server, when slowstart is active, or no value if not in slowstart."),
706 [ST_F_LBTOT] = IST("Total number of times a service was selected, either for new sessions, or when redispatching."),
707 [ST_F_TRACKED] = IST("Id of proxy/server if tracking is enabled."),
708 [ST_F_TYPE] = IST("Service type (0=frontend, 1=backend, 2=server, 3=socket/listener)."),
709 [ST_F_RATE] = IST("Current number of sessions per second over last elapsed second."),
710 [ST_F_RATE_LIM] = IST("Configured limit on new sessions per second."),
711 [ST_F_RATE_MAX] = IST("Maximum observed number of sessions per second."),
Christopher Faulete019d182019-11-21 14:35:46 +0100712 [ST_F_CHECK_STATUS] = IST("Status of last health check (HCHK_STATUS_* values)."),
Christopher Fauletf959d082019-02-07 15:38:42 +0100713 [ST_F_CHECK_CODE] = IST("layer5-7 code, if available of the last health check."),
Christopher Faulet4ab0efb2020-02-27 16:12:07 +0100714 [ST_F_CHECK_DURATION] = IST("Total duration of the latest server health check, in seconds."),
Christopher Fauletf959d082019-02-07 15:38:42 +0100715 [ST_F_HRSP_1XX] = IST("Total number of HTTP responses."),
716 [ST_F_HRSP_2XX] = IST("Total number of HTTP responses."),
717 [ST_F_HRSP_3XX] = IST("Total number of HTTP responses."),
718 [ST_F_HRSP_4XX] = IST("Total number of HTTP responses."),
719 [ST_F_HRSP_5XX] = IST("Total number of HTTP responses."),
720 [ST_F_HRSP_OTHER] = IST("Total number of HTTP responses."),
721 [ST_F_HANAFAIL] = IST("Total number of failed health checks."),
722 [ST_F_REQ_RATE] = IST("Current number of HTTP requests per second over last elapsed second."),
723 [ST_F_REQ_RATE_MAX] = IST("Maximum observed number of HTTP requests per second."),
724 [ST_F_REQ_TOT] = IST("Total number of HTTP requests received."),
725 [ST_F_CLI_ABRT] = IST("Total number of data transfers aborted by the client."),
726 [ST_F_SRV_ABRT] = IST("Total number of data transfers aborted by the server."),
727 [ST_F_COMP_IN] = IST("Total number of HTTP response bytes fed to the compressor."),
728 [ST_F_COMP_OUT] = IST("Total number of HTTP response bytes emitted by the compressor."),
729 [ST_F_COMP_BYP] = IST("Total number of bytes that bypassed the HTTP compressor (CPU/BW limit)."),
730 [ST_F_COMP_RSP] = IST("Total number of HTTP responses that were compressed."),
731 [ST_F_LASTSESS] = IST("Number of seconds since last session assigned to server/backend."),
732 [ST_F_LAST_CHK] = IST("Last health check contents or textual error"),
733 [ST_F_LAST_AGT] = IST("Last agent check contents or textual error"),
734 [ST_F_QTIME] = IST("Avg. queue time for last 1024 successful connections."),
735 [ST_F_CTIME] = IST("Avg. connect time for last 1024 successful connections."),
736 [ST_F_RTIME] = IST("Avg. response time for last 1024 successful connections."),
737 [ST_F_TTIME] = IST("Avg. total time for last 1024 successful connections."),
738 [ST_F_AGENT_STATUS] = IST("Status of last agent check."),
739 [ST_F_AGENT_CODE] = IST("Numeric code reported by agent if any (unused for now)."),
740 [ST_F_AGENT_DURATION] = IST("Time in ms taken to finish last agent check."),
741 [ST_F_CHECK_DESC] = IST("Short human-readable description of the last health status."),
742 [ST_F_AGENT_DESC] = IST("Short human-readable description of the last agent status."),
743 [ST_F_CHECK_RISE] = IST("Server's \"rise\" parameter used by health checks"),
744 [ST_F_CHECK_FALL] = IST("Server's \"fall\" parameter used by health checks"),
745 [ST_F_CHECK_HEALTH] = IST("Server's health check value between 0 and rise+fall-1"),
746 [ST_F_AGENT_RISE] = IST("Agent's \"rise\" parameter, normally 1."),
747 [ST_F_AGENT_FALL] = IST("Agent's \"fall\" parameter, normally 1."),
748 [ST_F_AGENT_HEALTH] = IST("Agent's health parameter, between 0 and rise+fall-1"),
749 [ST_F_ADDR] = IST("address:port or \"unix\". IPv6 has brackets around the address."),
750 [ST_F_COOKIE] = IST("Server's cookie value or backend's cookie name."),
751 [ST_F_MODE] = IST("Proxy mode (tcp, http, health, unknown)."),
752 [ST_F_ALGO] = IST("Load balancing algorithm."),
753 [ST_F_CONN_RATE] = IST("Current number of connections per second over the last elapsed second."),
754 [ST_F_CONN_RATE_MAX] = IST("Maximum observed number of connections per second."),
755 [ST_F_CONN_TOT] = IST("Total number of connections."),
756 [ST_F_INTERCEPTED] = IST("Total number of intercepted HTTP requests."),
757 [ST_F_DCON] = IST("Total number of requests denied by \"tcp-request connection\" rules."),
758 [ST_F_DSES] = IST("Total number of requests denied by \"tcp-request session\" rules."),
759 [ST_F_WREW] = IST("Total number of failed header rewriting warnings."),
760 [ST_F_CONNECT] = IST("Total number of connection establishment attempts."),
761 [ST_F_REUSE] = IST("Total number of connection reuses."),
762 [ST_F_CACHE_LOOKUPS] = IST("Total number of HTTP cache lookups."),
763 [ST_F_CACHE_HITS] = IST("Total number of HTTP cache hits."),
Christopher Fauletbd767f72019-11-08 15:24:32 +0100764 [ST_F_SRV_ICUR] = IST("Current number of idle connections available for reuse"),
765 [ST_F_SRV_ILIM] = IST("Limit on the number of available idle connections"),
Christopher Faulet5df597a2019-11-08 15:05:31 +0100766 [ST_F_QT_MAX] = IST("Maximum observed time spent in the queue"),
767 [ST_F_CT_MAX] = IST("Maximum observed time spent waiting for a connection to complete"),
768 [ST_F_RT_MAX] = IST("Maximum observed time spent waiting for a server response"),
769 [ST_F_TT_MAX] = IST("Maximum observed total request+response time (request+queue+connect+response+processing)"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100770};
771
772/* Specific labels for all info fields. Empty by default. */
773const struct ist promex_inf_metric_labels[INF_TOTAL_FIELDS] = {
774 [INF_NAME] = IST(""),
775 [INF_VERSION] = IST(""),
776 [INF_RELEASE_DATE] = IST(""),
777 [INF_NBTHREAD] = IST(""),
778 [INF_NBPROC] = IST(""),
779 [INF_PROCESS_NUM] = IST(""),
780 [INF_PID] = IST(""),
781 [INF_UPTIME] = IST(""),
782 [INF_UPTIME_SEC] = IST(""),
783 [INF_MEMMAX_MB] = IST(""),
784 [INF_POOL_ALLOC_MB] = IST(""),
785 [INF_POOL_USED_MB] = IST(""),
786 [INF_POOL_FAILED] = IST(""),
787 [INF_ULIMIT_N] = IST(""),
788 [INF_MAXSOCK] = IST(""),
789 [INF_MAXCONN] = IST(""),
790 [INF_HARD_MAXCONN] = IST(""),
791 [INF_CURR_CONN] = IST(""),
792 [INF_CUM_CONN] = IST(""),
793 [INF_CUM_REQ] = IST(""),
794 [INF_MAX_SSL_CONNS] = IST(""),
795 [INF_CURR_SSL_CONNS] = IST(""),
796 [INF_CUM_SSL_CONNS] = IST(""),
797 [INF_MAXPIPES] = IST(""),
798 [INF_PIPES_USED] = IST(""),
799 [INF_PIPES_FREE] = IST(""),
800 [INF_CONN_RATE] = IST(""),
801 [INF_CONN_RATE_LIMIT] = IST(""),
802 [INF_MAX_CONN_RATE] = IST(""),
803 [INF_SESS_RATE] = IST(""),
804 [INF_SESS_RATE_LIMIT] = IST(""),
805 [INF_MAX_SESS_RATE] = IST(""),
806 [INF_SSL_RATE] = IST(""),
807 [INF_SSL_RATE_LIMIT] = IST(""),
808 [INF_MAX_SSL_RATE] = IST(""),
809 [INF_SSL_FRONTEND_KEY_RATE] = IST(""),
810 [INF_SSL_FRONTEND_MAX_KEY_RATE] = IST(""),
811 [INF_SSL_FRONTEND_SESSION_REUSE_PCT] = IST(""),
812 [INF_SSL_BACKEND_KEY_RATE] = IST(""),
813 [INF_SSL_BACKEND_MAX_KEY_RATE] = IST(""),
814 [INF_SSL_CACHE_LOOKUPS] = IST(""),
815 [INF_SSL_CACHE_MISSES] = IST(""),
816 [INF_COMPRESS_BPS_IN] = IST(""),
817 [INF_COMPRESS_BPS_OUT] = IST(""),
818 [INF_COMPRESS_BPS_RATE_LIM] = IST(""),
819 [INF_ZLIB_MEM_USAGE] = IST(""),
820 [INF_MAX_ZLIB_MEM_USAGE] = IST(""),
821 [INF_TASKS] = IST(""),
822 [INF_RUN_QUEUE] = IST(""),
823 [INF_IDLE_PCT] = IST(""),
824 [INF_NODE] = IST(""),
825 [INF_DESCRIPTION] = IST(""),
826 [INF_STOPPING] = IST(""),
827 [INF_JOBS] = IST(""),
828 [INF_UNSTOPPABLE_JOBS] = IST(""),
829 [INF_LISTENERS] = IST(""),
830 [INF_ACTIVE_PEERS] = IST(""),
831 [INF_CONNECTED_PEERS] = IST(""),
832 [INF_DROPPED_LOGS] = IST(""),
833 [INF_BUSY_POLLING] = IST(""),
834};
835
836/* Specific labels for all stats fields. Empty by default. */
837const struct ist promex_st_metric_labels[ST_F_TOTAL_FIELDS] = {
838 [ST_F_PXNAME] = IST(""),
839 [ST_F_SVNAME] = IST(""),
840 [ST_F_QCUR] = IST(""),
841 [ST_F_QMAX] = IST(""),
842 [ST_F_SCUR] = IST(""),
843 [ST_F_SMAX] = IST(""),
844 [ST_F_SLIM] = IST(""),
845 [ST_F_STOT] = IST(""),
846 [ST_F_BIN] = IST(""),
847 [ST_F_BOUT] = IST(""),
848 [ST_F_DREQ] = IST(""),
849 [ST_F_DRESP] = IST(""),
850 [ST_F_EREQ] = IST(""),
851 [ST_F_ECON] = IST(""),
852 [ST_F_ERESP] = IST(""),
853 [ST_F_WRETR] = IST(""),
854 [ST_F_WREDIS] = IST(""),
855 [ST_F_STATUS] = IST(""),
856 [ST_F_WEIGHT] = IST(""),
857 [ST_F_ACT] = IST(""),
858 [ST_F_BCK] = IST(""),
859 [ST_F_CHKFAIL] = IST(""),
860 [ST_F_CHKDOWN] = IST(""),
861 [ST_F_LASTCHG] = IST(""),
862 [ST_F_DOWNTIME] = IST(""),
863 [ST_F_QLIMIT] = IST(""),
864 [ST_F_PID] = IST(""),
865 [ST_F_IID] = IST(""),
866 [ST_F_SID] = IST(""),
867 [ST_F_THROTTLE] = IST(""),
868 [ST_F_LBTOT] = IST(""),
869 [ST_F_TRACKED] = IST(""),
870 [ST_F_TYPE] = IST(""),
871 [ST_F_RATE] = IST(""),
872 [ST_F_RATE_LIM] = IST(""),
873 [ST_F_RATE_MAX] = IST(""),
874 [ST_F_CHECK_STATUS] = IST(""),
875 [ST_F_CHECK_CODE] = IST(""),
876 [ST_F_CHECK_DURATION] = IST(""),
877 [ST_F_HRSP_1XX] = IST("code=\"1xx\""),
878 [ST_F_HRSP_2XX] = IST("code=\"2xx\""),
879 [ST_F_HRSP_3XX] = IST("code=\"3xx\""),
880 [ST_F_HRSP_4XX] = IST("code=\"4xx\""),
881 [ST_F_HRSP_5XX] = IST("code=\"5xx\""),
882 [ST_F_HRSP_OTHER] = IST("code=\"other\""),
883 [ST_F_HANAFAIL] = IST(""),
884 [ST_F_REQ_RATE] = IST(""),
885 [ST_F_REQ_RATE_MAX] = IST(""),
886 [ST_F_REQ_TOT] = IST(""),
887 [ST_F_CLI_ABRT] = IST(""),
888 [ST_F_SRV_ABRT] = IST(""),
889 [ST_F_COMP_IN] = IST(""),
890 [ST_F_COMP_OUT] = IST(""),
891 [ST_F_COMP_BYP] = IST(""),
892 [ST_F_COMP_RSP] = IST(""),
893 [ST_F_LASTSESS] = IST(""),
894 [ST_F_LAST_CHK] = IST(""),
895 [ST_F_LAST_AGT] = IST(""),
896 [ST_F_QTIME] = IST(""),
897 [ST_F_CTIME] = IST(""),
898 [ST_F_RTIME] = IST(""),
899 [ST_F_TTIME] = IST(""),
900 [ST_F_AGENT_STATUS] = IST(""),
901 [ST_F_AGENT_CODE] = IST(""),
902 [ST_F_AGENT_DURATION] = IST(""),
903 [ST_F_CHECK_DESC] = IST(""),
904 [ST_F_AGENT_DESC] = IST(""),
905 [ST_F_CHECK_RISE] = IST(""),
906 [ST_F_CHECK_FALL] = IST(""),
907 [ST_F_CHECK_HEALTH] = IST(""),
908 [ST_F_AGENT_RISE] = IST(""),
909 [ST_F_AGENT_FALL] = IST(""),
910 [ST_F_AGENT_HEALTH] = IST(""),
911 [ST_F_ADDR] = IST(""),
912 [ST_F_COOKIE] = IST(""),
913 [ST_F_MODE] = IST(""),
914 [ST_F_ALGO] = IST(""),
915 [ST_F_CONN_RATE] = IST(""),
916 [ST_F_CONN_RATE_MAX] = IST(""),
917 [ST_F_CONN_TOT] = IST(""),
918 [ST_F_INTERCEPTED] = IST(""),
919 [ST_F_DCON] = IST(""),
920 [ST_F_DSES] = IST(""),
921 [ST_F_WREW] = IST(""),
922 [ST_F_CONNECT] = IST(""),
923 [ST_F_REUSE] = IST(""),
924 [ST_F_CACHE_LOOKUPS] = IST(""),
925 [ST_F_CACHE_HITS] = IST(""),
926};
927
928/* Type for all info fields. "untyped" is used for unsupported field. */
929const struct ist promex_inf_metric_types[INF_TOTAL_FIELDS] = {
930 [INF_NAME] = IST("untyped"),
931 [INF_VERSION] = IST("untyped"),
932 [INF_RELEASE_DATE] = IST("untyped"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200933 [INF_NBTHREAD] = IST("gauge"),
934 [INF_NBPROC] = IST("gauge"),
935 [INF_PROCESS_NUM] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100936 [INF_PID] = IST("untyped"),
937 [INF_UPTIME] = IST("untyped"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200938 [INF_UPTIME_SEC] = IST("gauge"),
939 [INF_MEMMAX_MB] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100940 [INF_POOL_ALLOC_MB] = IST("gauge"),
941 [INF_POOL_USED_MB] = IST("gauge"),
942 [INF_POOL_FAILED] = IST("counter"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200943 [INF_ULIMIT_N] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100944 [INF_MAXSOCK] = IST("gauge"),
945 [INF_MAXCONN] = IST("gauge"),
946 [INF_HARD_MAXCONN] = IST("gauge"),
947 [INF_CURR_CONN] = IST("gauge"),
948 [INF_CUM_CONN] = IST("counter"),
949 [INF_CUM_REQ] = IST("counter"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200950 [INF_MAX_SSL_CONNS] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100951 [INF_CURR_SSL_CONNS] = IST("gauge"),
952 [INF_CUM_SSL_CONNS] = IST("counter"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200953 [INF_MAXPIPES] = IST("gauge"),
954 [INF_PIPES_USED] = IST("counter"),
955 [INF_PIPES_FREE] = IST("counter"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100956 [INF_CONN_RATE] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200957 [INF_CONN_RATE_LIMIT] = IST("gauge"),
958 [INF_MAX_CONN_RATE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100959 [INF_SESS_RATE] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200960 [INF_SESS_RATE_LIMIT] = IST("gauge"),
961 [INF_MAX_SESS_RATE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100962 [INF_SSL_RATE] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200963 [INF_SSL_RATE_LIMIT] = IST("gauge"),
964 [INF_MAX_SSL_RATE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100965 [INF_SSL_FRONTEND_KEY_RATE] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200966 [INF_SSL_FRONTEND_MAX_KEY_RATE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100967 [INF_SSL_FRONTEND_SESSION_REUSE_PCT] = IST("gauge"),
968 [INF_SSL_BACKEND_KEY_RATE] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200969 [INF_SSL_BACKEND_MAX_KEY_RATE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100970 [INF_SSL_CACHE_LOOKUPS] = IST("counter"),
971 [INF_SSL_CACHE_MISSES] = IST("counter"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200972 [INF_COMPRESS_BPS_IN] = IST("counter"),
973 [INF_COMPRESS_BPS_OUT] = IST("counter"),
974 [INF_COMPRESS_BPS_RATE_LIM] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100975 [INF_ZLIB_MEM_USAGE] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200976 [INF_MAX_ZLIB_MEM_USAGE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100977 [INF_TASKS] = IST("gauge"),
Christopher Fauletf782c232019-04-17 16:04:44 +0200978 [INF_RUN_QUEUE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100979 [INF_IDLE_PCT] = IST("gauge"),
980 [INF_NODE] = IST("untyped"),
981 [INF_DESCRIPTION] = IST("untyped"),
982 [INF_STOPPING] = IST("gauge"),
983 [INF_JOBS] = IST("gauge"),
984 [INF_UNSTOPPABLE_JOBS] = IST("gauge"),
985 [INF_LISTENERS] = IST("gauge"),
986 [INF_ACTIVE_PEERS] = IST("gauge"),
987 [INF_CONNECTED_PEERS] = IST("gauge"),
988 [INF_DROPPED_LOGS] = IST("counter"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200989 [INF_BUSY_POLLING] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100990};
991
992/* Type for all stats fields. "untyped" is used for unsupported field. */
993const struct ist promex_st_metric_types[ST_F_TOTAL_FIELDS] = {
994 [ST_F_PXNAME] = IST("untyped"),
995 [ST_F_SVNAME] = IST("untyped"),
996 [ST_F_QCUR] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200997 [ST_F_QMAX] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +0100998 [ST_F_SCUR] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +0200999 [ST_F_SMAX] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +01001000 [ST_F_SLIM] = IST("gauge"),
1001 [ST_F_STOT] = IST("counter"),
1002 [ST_F_BIN] = IST("counter"),
1003 [ST_F_BOUT] = IST("counter"),
1004 [ST_F_DREQ] = IST("counter"),
1005 [ST_F_DRESP] = IST("counter"),
1006 [ST_F_EREQ] = IST("counter"),
1007 [ST_F_ECON] = IST("counter"),
1008 [ST_F_ERESP] = IST("counter"),
1009 [ST_F_WRETR] = IST("counter"),
1010 [ST_F_WREDIS] = IST("counter"),
1011 [ST_F_STATUS] = IST("gauge"),
1012 [ST_F_WEIGHT] = IST("gauge"),
1013 [ST_F_ACT] = IST("gauge"),
1014 [ST_F_BCK] = IST("gauge"),
1015 [ST_F_CHKFAIL] = IST("counter"),
1016 [ST_F_CHKDOWN] = IST("counter"),
1017 [ST_F_LASTCHG] = IST("gauge"),
1018 [ST_F_DOWNTIME] = IST("counter"),
1019 [ST_F_QLIMIT] = IST("gauge"),
1020 [ST_F_PID] = IST("untyped"),
1021 [ST_F_IID] = IST("untyped"),
1022 [ST_F_SID] = IST("untyped"),
1023 [ST_F_THROTTLE] = IST("gauge"),
1024 [ST_F_LBTOT] = IST("counter"),
1025 [ST_F_TRACKED] = IST("untyped"),
1026 [ST_F_TYPE] = IST("untyped"),
Christopher Fauletc58fc0d2019-04-18 10:10:49 +02001027 [ST_F_RATE] = IST("untyped"),
Christopher Fauletf959d082019-02-07 15:38:42 +01001028 [ST_F_RATE_LIM] = IST("gauge"),
Christopher Faulet769a92d2019-04-18 10:18:44 +02001029 [ST_F_RATE_MAX] = IST("gauge"),
Christopher Faulete019d182019-11-21 14:35:46 +01001030 [ST_F_CHECK_STATUS] = IST("gauge"),
1031 [ST_F_CHECK_CODE] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +01001032 [ST_F_CHECK_DURATION] = IST("gauge"),
1033 [ST_F_HRSP_1XX] = IST("counter"),
1034 [ST_F_HRSP_2XX] = IST("counter"),
1035 [ST_F_HRSP_3XX] = IST("counter"),
1036 [ST_F_HRSP_4XX] = IST("counter"),
1037 [ST_F_HRSP_5XX] = IST("counter"),
1038 [ST_F_HRSP_OTHER] = IST("counter"),
1039 [ST_F_HANAFAIL] = IST("counter"),
Christopher Fauletc58fc0d2019-04-18 10:10:49 +02001040 [ST_F_REQ_RATE] = IST("untyped"),
Christopher Faulet769a92d2019-04-18 10:18:44 +02001041 [ST_F_REQ_RATE_MAX] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +01001042 [ST_F_REQ_TOT] = IST("counter"),
1043 [ST_F_CLI_ABRT] = IST("counter"),
1044 [ST_F_SRV_ABRT] = IST("counter"),
1045 [ST_F_COMP_IN] = IST("counter"),
1046 [ST_F_COMP_OUT] = IST("counter"),
1047 [ST_F_COMP_BYP] = IST("counter"),
1048 [ST_F_COMP_RSP] = IST("counter"),
1049 [ST_F_LASTSESS] = IST("gauge"),
1050 [ST_F_LAST_CHK] = IST("untyped"),
1051 [ST_F_LAST_AGT] = IST("untyped"),
1052 [ST_F_QTIME] = IST("gauge"),
1053 [ST_F_CTIME] = IST("gauge"),
1054 [ST_F_RTIME] = IST("gauge"),
1055 [ST_F_TTIME] = IST("gauge"),
1056 [ST_F_AGENT_STATUS] = IST("untyped"),
1057 [ST_F_AGENT_CODE] = IST("untyped"),
1058 [ST_F_AGENT_DURATION] = IST("gauge"),
1059 [ST_F_CHECK_DESC] = IST("untyped"),
1060 [ST_F_AGENT_DESC] = IST("untyped"),
1061 [ST_F_CHECK_RISE] = IST("gauge"),
1062 [ST_F_CHECK_FALL] = IST("gauge"),
1063 [ST_F_CHECK_HEALTH] = IST("gauge"),
1064 [ST_F_AGENT_RISE] = IST("gauge"),
1065 [ST_F_AGENT_FALL] = IST("gauge"),
1066 [ST_F_AGENT_HEALTH] = IST("gauge"),
1067 [ST_F_ADDR] = IST("untyped"),
1068 [ST_F_COOKIE] = IST("untyped"),
1069 [ST_F_MODE] = IST("untyped"),
1070 [ST_F_ALGO] = IST("untyped"),
Christopher Fauletc58fc0d2019-04-18 10:10:49 +02001071 [ST_F_CONN_RATE] = IST("untyped"),
Christopher Faulet769a92d2019-04-18 10:18:44 +02001072 [ST_F_CONN_RATE_MAX] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +01001073 [ST_F_CONN_TOT] = IST("counter"),
1074 [ST_F_INTERCEPTED] = IST("counter"),
1075 [ST_F_DCON] = IST("counter"),
1076 [ST_F_DSES] = IST("counter"),
1077 [ST_F_WREW] = IST("counter"),
1078 [ST_F_CONNECT] = IST("counter"),
1079 [ST_F_REUSE] = IST("counter"),
1080 [ST_F_CACHE_LOOKUPS] = IST("counter"),
1081 [ST_F_CACHE_HITS] = IST("counter"),
Christopher Fauletbd767f72019-11-08 15:24:32 +01001082 [ST_F_SRV_ICUR] = IST("gauge"),
1083 [ST_F_SRV_ILIM] = IST("gauge"),
Christopher Faulet5df597a2019-11-08 15:05:31 +01001084 [ST_F_QT_MAX] = IST("gauge"),
1085 [ST_F_CT_MAX] = IST("gauge"),
1086 [ST_F_RT_MAX] = IST("gauge"),
1087 [ST_F_TT_MAX] = IST("gauge"),
Christopher Fauletf959d082019-02-07 15:38:42 +01001088};
1089
Christopher Faulet8e40fa22019-09-06 16:10:19 +02001090/* Return the server status: 0=DOWN, 1=UP, 2=MAINT, 3=DRAIN, 4=NOLB. */
Christopher Fauletf959d082019-02-07 15:38:42 +01001091static int promex_srv_status(struct server *sv)
1092{
Christopher Fauletf959d082019-02-07 15:38:42 +01001093 int state = 0;
1094
Christopher Fauletf959d082019-02-07 15:38:42 +01001095 if (sv->cur_state == SRV_ST_RUNNING || sv->cur_state == SRV_ST_STARTING) {
1096 state = 1;
1097 if (sv->cur_admin & SRV_ADMF_DRAIN)
Christopher Faulet8e40fa22019-09-06 16:10:19 +02001098 state = 3;
Christopher Fauletf959d082019-02-07 15:38:42 +01001099 }
Christopher Faulet8e40fa22019-09-06 16:10:19 +02001100 else if (sv->cur_state == SRV_ST_STOPPING)
1101 state = 4;
1102
1103 if (sv->cur_admin & SRV_ADMF_MAINT)
1104 state = 2;
Christopher Fauletf959d082019-02-07 15:38:42 +01001105
1106 return state;
1107}
1108
1109/* Convert a field to its string representation and write it in <out>, followed
1110 * by a newline, if there is enough space. non-numeric value are converted in
1111 * "Nan" because Prometheus only support numerical values (but it is unexepceted
1112 * to process this kind of value). It returns 1 on success. Otherwise, it
1113 * returns 0. The buffer's length must not exceed <max> value.
1114 */
1115static int promex_metric_to_str(struct buffer *out, struct field *f, size_t max)
1116{
1117 int ret = 0;
1118
1119 switch (field_format(f, 0)) {
1120 case FF_EMPTY: ret = chunk_strcat(out, "Nan\n"); break;
1121 case FF_S32: ret = chunk_appendf(out, "%d\n", f->u.s32); break;
1122 case FF_U32: ret = chunk_appendf(out, "%u\n", f->u.u32); break;
1123 case FF_S64: ret = chunk_appendf(out, "%lld\n", (long long)f->u.s64); break;
1124 case FF_U64: ret = chunk_appendf(out, "%llu\n", (unsigned long long)f->u.u64); break;
Christopher Faulete86bf652019-09-24 16:35:19 +02001125 case FF_FLT: ret = chunk_appendf(out, "%f\n", f->u.flt); break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001126 case FF_STR: ret = chunk_strcat(out, "Nan\n"); break;
1127 default: ret = chunk_strcat(out, "Nan\n"); break;
1128 }
1129 if (!ret || out->data > max)
1130 return 0;
1131 return 1;
1132}
1133
1134/* Concatenate the <prefix> with the field name using the array
1135 * <promex_st_metric_names> and store it in <name>. The field type is in
1136 * <appctx->st2>. This function never fails but relies on
1137 * <PROMEX_MAX_NAME_LEN>. So by sure the result is small enougth to be copied in
1138 * <name>
1139 */
1140static void promex_metric_name(struct appctx *appctx, struct ist *name, const struct ist prefix)
1141{
1142 const struct ist *names;
1143
1144 names = ((appctx->ctx.stats.flags & PROMEX_FL_INFO_METRIC)
1145 ? promex_inf_metric_names
1146 : promex_st_metric_names);
1147
1148 istcat(name, prefix, PROMEX_MAX_NAME_LEN);
1149 istcat(name, names[appctx->st2], PROMEX_MAX_NAME_LEN);
1150}
1151
1152/* Dump the header lines for <metric>. It is its #HELP and #TYPE strings. It
1153 * returns 1 on success. Otherwise, if <out> length exceeds <max>, it returns 0.
1154 */
1155static int promex_dump_metric_header(struct appctx *appctx, struct htx *htx,
1156 const struct ist name, struct ist *out, size_t max)
1157{
1158 const struct ist *desc, *types;
1159
1160 if (appctx->ctx.stats.flags & PROMEX_FL_INFO_METRIC) {
1161 desc = promex_inf_metric_desc;
1162 types = promex_inf_metric_types;
1163 }
1164 else {
1165 desc = promex_st_metric_desc;
1166 types = promex_st_metric_types;
1167 }
1168
Anthonin Bonnefoydd4e4ef2019-08-07 17:45:25 +02001169 if (istcat(out, ist("# HELP "), max) == -1 ||
Christopher Fauletf959d082019-02-07 15:38:42 +01001170 istcat(out, name, max) == -1 ||
1171 istcat(out, ist(" "), max) == -1 ||
1172 istcat(out, desc[appctx->st2], max) == -1 ||
Anthonin Bonnefoydd4e4ef2019-08-07 17:45:25 +02001173 istcat(out, ist("\n# TYPE "), max) == -1 ||
Christopher Fauletf959d082019-02-07 15:38:42 +01001174 istcat(out, name, max) == -1 ||
1175 istcat(out, ist(" "), max) == -1 ||
1176 istcat(out, types[appctx->st2], max) == -1 ||
1177 istcat(out, ist("\n"), max) == -1)
1178 goto full;
1179
1180 return 1;
1181
1182 full:
1183 return 0;
1184}
1185
1186/* Dump the line for <metric>. It starts by the metric name followed by its
1187 * labels (proxy name, server name...) between braces and finally its value. If
1188 * not already done, the header lines are dumped first. It returns 1 on
1189 * success. Otherwise if <out> length exceeds <max>, it returns 0.
1190 */
1191static int promex_dump_metric(struct appctx *appctx, struct htx *htx,
1192 const struct ist prefix, struct field *metric,
1193 struct ist *out, size_t max)
1194{
1195 struct ist name = { .ptr = (char[PROMEX_MAX_NAME_LEN]){ 0 }, .len = 0 };
1196 size_t len = out->len;
1197
1198 if (out->len + PROMEX_MAX_METRIC_LENGTH > max)
1199 return 0;
1200
1201 promex_metric_name(appctx, &name, prefix);
1202 if ((appctx->ctx.stats.flags & PROMEX_FL_METRIC_HDR) &&
1203 !promex_dump_metric_header(appctx, htx, name, out, max))
1204 goto full;
1205
1206 if (appctx->ctx.stats.flags & PROMEX_FL_INFO_METRIC) {
1207 const struct ist label = promex_inf_metric_labels[appctx->st2];
1208
1209 if (istcat(out, name, max) == -1 ||
1210 (label.len && istcat(out, ist("{"), max) == -1) ||
1211 (label.len && istcat(out, label, max) == -1) ||
1212 (label.len && istcat(out, ist("}"), max) == -1) ||
1213 istcat(out, ist(" "), max) == -1)
1214 goto full;
1215 }
1216 else {
1217 struct proxy *px = appctx->ctx.stats.px;
1218 struct server *srv = appctx->ctx.stats.sv;
1219 const struct ist label = promex_st_metric_labels[appctx->st2];
1220
1221 if (istcat(out, name, max) == -1 ||
1222 istcat(out, ist("{proxy=\""), max) == -1 ||
1223 istcat(out, ist2(px->id, strlen(px->id)), max) == -1 ||
1224 istcat(out, ist("\""), max) == -1 ||
1225 (srv && istcat(out, ist(",server=\""), max) == -1) ||
1226 (srv && istcat(out, ist2(srv->id, strlen(srv->id)), max) == -1) ||
1227 (srv && istcat(out, ist("\""), max) == -1) ||
1228 (label.len && istcat(out, ist(","), max) == -1) ||
1229 (label.len && istcat(out, label, max) == -1) ||
1230 istcat(out, ist("} "), max) == -1)
1231 goto full;
1232 }
1233
1234 trash.data = out->len;
1235 if (!promex_metric_to_str(&trash, metric, max))
1236 goto full;
1237 out->len = trash.data;
1238
1239 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1240 return 1;
1241 full:
1242 // Restore previous length
1243 out->len = len;
1244 return 0;
1245
1246}
1247
1248
1249/* Dump global metrics (prefixed by "haproxy_process_"). It returns 1 on sucess,
1250 * 0 if <htx> is full and -1 in case of any error. */
1251static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
1252{
1253 static struct ist prefix = IST("haproxy_process_");
1254 struct field metric;
1255 struct channel *chn = si_ic(appctx->owner);
1256 struct ist out = ist2(trash.area, 0);
Christopher Faulet94d837e2019-07-03 11:43:17 +02001257 size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx));
Christopher Fauletf959d082019-02-07 15:38:42 +01001258 int ret = 1;
1259
1260#ifdef USE_OPENSSL
1261 int ssl_sess_rate = read_freq_ctr(&global.ssl_per_sec);
1262 int ssl_key_rate = read_freq_ctr(&global.ssl_fe_keys_per_sec);
1263 int ssl_reuse = 0;
1264
1265 if (ssl_key_rate < ssl_sess_rate) {
1266 /* count the ssl reuse ratio and avoid overflows in both directions */
1267 ssl_reuse = 100 - (100 * ssl_key_rate + (ssl_sess_rate - 1) / 2) / ssl_sess_rate;
1268 }
1269#endif
Christopher Fauletf959d082019-02-07 15:38:42 +01001270 while (appctx->st2 && appctx->st2 < INF_TOTAL_FIELDS) {
1271 switch (appctx->st2) {
1272 case INF_NBTHREAD:
1273 metric = mkf_u32(FO_CONFIG|FS_SERVICE, global.nbthread);
1274 break;
1275 case INF_NBPROC:
1276 metric = mkf_u32(FO_CONFIG|FS_SERVICE, global.nbproc);
1277 break;
1278 case INF_PROCESS_NUM:
1279 metric = mkf_u32(FO_KEY, relative_pid);
1280 break;
1281 case INF_UPTIME_SEC:
Christopher Faulet8c8e4b12019-04-18 10:15:15 +02001282 metric = mkf_u32(FN_DURATION, start_date.tv_sec);
Christopher Fauletf959d082019-02-07 15:38:42 +01001283 break;
1284 case INF_MEMMAX_MB:
Christopher Faulet8c8e4b12019-04-18 10:15:15 +02001285 metric = mkf_u64(FO_CONFIG|FN_LIMIT, global.rlimit_memmax * 1048576L);
Christopher Fauletf959d082019-02-07 15:38:42 +01001286 break;
1287 case INF_POOL_ALLOC_MB:
Christopher Faulet8c8e4b12019-04-18 10:15:15 +02001288 metric = mkf_u64(0, pool_total_allocated());
Christopher Fauletf959d082019-02-07 15:38:42 +01001289 break;
1290 case INF_POOL_USED_MB:
Christopher Faulet8c8e4b12019-04-18 10:15:15 +02001291 metric = mkf_u64(0, pool_total_used());
Christopher Fauletf959d082019-02-07 15:38:42 +01001292 break;
1293 case INF_POOL_FAILED:
1294 metric = mkf_u32(FN_COUNTER, pool_total_failures());
1295 break;
1296 case INF_ULIMIT_N:
1297 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.rlimit_nofile);
1298 break;
1299 case INF_MAXSOCK:
1300 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.maxsock);
1301 break;
1302 case INF_MAXCONN:
1303 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.maxconn);
1304 break;
1305 case INF_HARD_MAXCONN:
1306 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.hardmaxconn);
1307 break;
1308 case INF_CURR_CONN:
1309 metric = mkf_u32(0, actconn);
1310 break;
1311 case INF_CUM_CONN:
1312 metric = mkf_u32(FN_COUNTER, totalconn);
1313 break;
1314 case INF_CUM_REQ:
1315 metric = mkf_u32(FN_COUNTER, global.req_count);
1316 break;
1317#ifdef USE_OPENSSL
1318 case INF_MAX_SSL_CONNS:
1319 metric = mkf_u32(FN_MAX, global.maxsslconn);
1320 break;
1321 case INF_CURR_SSL_CONNS:
1322 metric = mkf_u32(0, sslconns);
1323 break;
1324 case INF_CUM_SSL_CONNS:
1325 metric = mkf_u32(FN_COUNTER, totalsslconns);
1326 break;
1327#endif
1328 case INF_MAXPIPES:
1329 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.maxpipes);
1330 break;
1331 case INF_PIPES_USED:
1332 metric = mkf_u32(0, pipes_used);
1333 break;
1334 case INF_PIPES_FREE:
1335 metric = mkf_u32(0, pipes_free);
1336 break;
1337 case INF_CONN_RATE:
1338 metric = mkf_u32(FN_RATE, read_freq_ctr(&global.conn_per_sec));
1339 break;
1340 case INF_CONN_RATE_LIMIT:
1341 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.cps_lim);
1342 break;
1343 case INF_MAX_CONN_RATE:
1344 metric = mkf_u32(FN_MAX, global.cps_max);
1345 break;
1346 case INF_SESS_RATE:
1347 metric = mkf_u32(FN_RATE, read_freq_ctr(&global.sess_per_sec));
1348 break;
1349 case INF_SESS_RATE_LIMIT:
1350 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.sps_lim);
1351 break;
1352 case INF_MAX_SESS_RATE:
1353 metric = mkf_u32(FN_RATE, global.sps_max);
1354 break;
1355#ifdef USE_OPENSSL
1356 case INF_SSL_RATE:
1357 metric = mkf_u32(FN_RATE, ssl_sess_rate);
1358 break;
1359 case INF_SSL_RATE_LIMIT:
1360 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.ssl_lim);
1361 break;
1362 case INF_MAX_SSL_RATE:
1363 metric = mkf_u32(FN_MAX, global.ssl_max);
1364 break;
1365 case INF_SSL_FRONTEND_KEY_RATE:
1366 metric = mkf_u32(0, ssl_key_rate);
1367 break;
1368 case INF_SSL_FRONTEND_MAX_KEY_RATE:
1369 metric = mkf_u32(FN_MAX, global.ssl_fe_keys_max);
1370 break;
1371 case INF_SSL_FRONTEND_SESSION_REUSE_PCT:
1372 metric = mkf_u32(0, ssl_reuse);
1373 break;
1374 case INF_SSL_BACKEND_KEY_RATE:
1375 metric = mkf_u32(FN_RATE, read_freq_ctr(&global.ssl_be_keys_per_sec));
1376 break;
1377 case INF_SSL_BACKEND_MAX_KEY_RATE:
1378 metric = mkf_u32(FN_MAX, global.ssl_be_keys_max);
1379 break;
1380 case INF_SSL_CACHE_LOOKUPS:
1381 metric = mkf_u32(FN_COUNTER, global.shctx_lookups);
1382 break;
1383 case INF_SSL_CACHE_MISSES:
1384 metric = mkf_u32(FN_COUNTER, global.shctx_misses);
1385 break;
1386#endif
1387 case INF_COMPRESS_BPS_IN:
1388 metric = mkf_u32(FN_RATE, read_freq_ctr(&global.comp_bps_in));
1389 break;
1390 case INF_COMPRESS_BPS_OUT:
1391 metric = mkf_u32(FN_RATE, read_freq_ctr(&global.comp_bps_out));
1392 break;
1393 case INF_COMPRESS_BPS_RATE_LIM:
1394 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.comp_rate_lim);
1395 break;
1396#ifdef USE_ZLIB
1397 case INF_ZLIB_MEM_USAGE:
1398 metric = mkf_u32(0, zlib_used_memory);
1399 break;
1400 case INF_MAX_ZLIB_MEM_USAGE:
1401 metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.maxzlibmem);
1402 break;
1403#endif
1404 case INF_TASKS:
1405 metric = mkf_u32(0, nb_tasks_cur);
1406 break;
1407 case INF_RUN_QUEUE:
1408 metric = mkf_u32(0, tasks_run_queue_cur);
1409 break;
1410 case INF_IDLE_PCT:
Willy Tarreau76824a82019-06-02 10:38:48 +02001411 metric = mkf_u32(FN_AVG, ti->idle_pct);
Christopher Fauletf959d082019-02-07 15:38:42 +01001412 break;
1413 case INF_STOPPING:
1414 metric = mkf_u32(0, stopping);
1415 break;
1416 case INF_JOBS:
1417 metric = mkf_u32(0, jobs);
1418 break;
1419 case INF_UNSTOPPABLE_JOBS:
1420 metric = mkf_u32(0, unstoppable_jobs);
1421 break;
1422 case INF_LISTENERS:
1423 metric = mkf_u32(0, listeners);
1424 break;
1425 case INF_ACTIVE_PEERS:
1426 metric = mkf_u32(0, active_peers);
1427 break;
1428 case INF_CONNECTED_PEERS:
1429 metric = mkf_u32(0, connected_peers);
1430 break;
1431 case INF_DROPPED_LOGS:
1432 metric = mkf_u32(0, dropped_logs);
1433 break;
1434 case INF_BUSY_POLLING:
1435 metric = mkf_u32(0, !!(global.tune.options & GTUNE_BUSY_POLLING));
1436 break;
1437
1438 default:
1439 goto next_metric;
1440 }
1441
1442 if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
1443 goto full;
1444
1445 next_metric:
1446 appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
1447 appctx->st2 = promex_global_metrics[appctx->st2];
1448 }
1449
1450 end:
Christopher Faulet0f58c0b2019-07-04 10:03:28 +02001451 if (out.len) {
1452 if (!htx_add_data_atonce(htx, out))
1453 return -1; /* Unexpected and unrecoverable error */
1454 channel_add_input(chn, out.len);
1455 }
Christopher Fauletf959d082019-02-07 15:38:42 +01001456 return ret;
1457 full:
1458 ret = 0;
1459 goto end;
1460}
1461
1462/* Dump frontends metrics (prefixed by "haproxy_frontend_"). It returns 1 on sucess,
1463 * 0 if <htx> is full and -1 in case of any error. */
1464static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
1465{
1466 static struct ist prefix = IST("haproxy_frontend_");
1467 struct proxy *px;
1468 struct field metric;
1469 struct channel *chn = si_ic(appctx->owner);
1470 struct ist out = ist2(trash.area, 0);
Christopher Faulet94d837e2019-07-03 11:43:17 +02001471 size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx));
Christopher Fauletf959d082019-02-07 15:38:42 +01001472 int ret = 1;
1473
1474 while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) {
1475 while (appctx->ctx.stats.px) {
1476 px = appctx->ctx.stats.px;
1477
1478 /* skip the disabled proxies, global frontend and non-networked ones */
1479 if (px->state == PR_STSTOPPED || px->uuid <= 0 || !(px->cap & PR_CAP_FE))
1480 goto next_px;
1481
1482 switch (appctx->st2) {
1483 case ST_F_STATUS:
1484 metric = mkf_u32(FO_STATUS, px->state == PR_STREADY ? 1 : px->state == PR_STFULL ? 2 : 0);
1485 break;
1486 case ST_F_SCUR:
1487 metric = mkf_u32(0, px->feconn);
1488 break;
1489 case ST_F_SMAX:
1490 metric = mkf_u32(FN_MAX, px->fe_counters.conn_max);
1491 break;
1492 case ST_F_SLIM:
1493 metric = mkf_u32(FO_CONFIG|FN_LIMIT, px->maxconn);
1494 break;
1495 case ST_F_STOT:
1496 metric = mkf_u64(FN_COUNTER, px->fe_counters.cum_sess);
1497 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001498 case ST_F_RATE_LIM:
1499 metric = mkf_u32(FO_CONFIG|FN_LIMIT, px->fe_sps_lim);
1500 break;
1501 case ST_F_RATE_MAX:
1502 metric = mkf_u32(FN_MAX, px->fe_counters.sps_max);
1503 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001504 case ST_F_CONN_RATE_MAX:
1505 metric = mkf_u32(FN_MAX, px->fe_counters.cps_max);
1506 break;
1507 case ST_F_CONN_TOT:
1508 metric = mkf_u64(FN_COUNTER, px->fe_counters.cum_conn);
1509 break;
1510 case ST_F_BIN:
1511 metric = mkf_u64(FN_COUNTER, px->fe_counters.bytes_in);
1512 break;
1513 case ST_F_BOUT:
1514 metric = mkf_u64(FN_COUNTER, px->fe_counters.bytes_out);
1515 break;
1516 case ST_F_DREQ:
1517 metric = mkf_u64(FN_COUNTER, px->fe_counters.denied_req);
1518 break;
1519 case ST_F_DRESP:
1520 metric = mkf_u64(FN_COUNTER, px->fe_counters.denied_resp);
1521 break;
1522 case ST_F_EREQ:
1523 metric = mkf_u64(FN_COUNTER, px->fe_counters.failed_req);
1524 break;
1525 case ST_F_DCON:
1526 metric = mkf_u64(FN_COUNTER, px->fe_counters.denied_conn);
1527 break;
1528 case ST_F_DSES:
1529 metric = mkf_u64(FN_COUNTER, px->fe_counters.denied_sess);
1530 break;
1531 case ST_F_WREW:
1532 metric = mkf_u64(FN_COUNTER, px->fe_counters.failed_rewrites);
1533 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001534 case ST_F_REQ_RATE_MAX:
1535 if (px->mode != PR_MODE_HTTP)
1536 goto next_px;
1537 metric = mkf_u32(FN_MAX, px->fe_counters.p.http.rps_max);
1538 break;
1539 case ST_F_REQ_TOT:
1540 if (px->mode != PR_MODE_HTTP)
1541 goto next_px;
1542 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cum_req);
1543 break;
1544 case ST_F_HRSP_1XX:
1545 if (px->mode != PR_MODE_HTTP)
1546 goto next_px;
1547 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[1]);
1548 break;
1549 case ST_F_HRSP_2XX:
1550 if (px->mode != PR_MODE_HTTP)
1551 goto next_px;
1552 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1553 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[2]);
1554 break;
1555 case ST_F_HRSP_3XX:
1556 if (px->mode != PR_MODE_HTTP)
1557 goto next_px;
1558 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1559 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[3]);
1560 break;
1561 case ST_F_HRSP_4XX:
1562 if (px->mode != PR_MODE_HTTP)
1563 goto next_px;
1564 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1565 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[4]);
1566 break;
1567 case ST_F_HRSP_5XX:
1568 if (px->mode != PR_MODE_HTTP)
1569 goto next_px;
1570 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1571 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[5]);
1572 break;
1573 case ST_F_HRSP_OTHER:
1574 if (px->mode != PR_MODE_HTTP)
1575 goto next_px;
1576 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1577 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[0]);
1578 break;
1579 case ST_F_INTERCEPTED:
1580 if (px->mode != PR_MODE_HTTP)
1581 goto next_px;
1582 metric = mkf_u64(FN_COUNTER, px->fe_counters.intercepted_req);
1583 break;
1584 case ST_F_CACHE_LOOKUPS:
1585 if (px->mode != PR_MODE_HTTP)
1586 goto next_px;
1587 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cache_lookups);
1588 break;
1589 case ST_F_CACHE_HITS:
1590 if (px->mode != PR_MODE_HTTP)
1591 goto next_px;
1592 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cache_hits);
1593 break;
1594 case ST_F_COMP_IN:
1595 if (px->mode != PR_MODE_HTTP)
1596 goto next_px;
1597 metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_in);
1598 break;
1599 case ST_F_COMP_OUT:
1600 if (px->mode != PR_MODE_HTTP)
1601 goto next_px;
1602 metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_out);
1603 break;
1604 case ST_F_COMP_BYP:
1605 if (px->mode != PR_MODE_HTTP)
1606 goto next_px;
1607 metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_byp);
1608 break;
1609 case ST_F_COMP_RSP:
1610 if (px->mode != PR_MODE_HTTP)
1611 goto next_px;
1612 metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.comp_rsp);
1613 break;
1614
1615 default:
1616 goto next_metric;
1617 }
1618
1619 if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
1620 goto full;
1621 next_px:
1622 appctx->ctx.stats.px = px->next;
1623 }
1624 next_metric:
1625 appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
1626 appctx->ctx.stats.px = proxies_list;
1627 appctx->st2 = promex_front_metrics[appctx->st2];
1628 }
1629
1630 end:
Christopher Faulet0f58c0b2019-07-04 10:03:28 +02001631 if (out.len) {
1632 if (!htx_add_data_atonce(htx, out))
1633 return -1; /* Unexpected and unrecoverable error */
1634 channel_add_input(chn, out.len);
1635 }
Christopher Fauletf959d082019-02-07 15:38:42 +01001636 return ret;
1637 full:
1638 ret = 0;
1639 goto end;
1640}
1641
1642/* Dump backends metrics (prefixed by "haproxy_backend_"). It returns 1 on sucess,
1643 * 0 if <htx> is full and -1 in case of any error. */
1644static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
1645{
1646 static struct ist prefix = IST("haproxy_backend_");
1647 struct proxy *px;
1648 struct field metric;
1649 struct channel *chn = si_ic(appctx->owner);
1650 struct ist out = ist2(trash.area, 0);
Christopher Faulet94d837e2019-07-03 11:43:17 +02001651 size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx));
Christopher Fauletf959d082019-02-07 15:38:42 +01001652 int ret = 1;
1653 uint32_t weight;
Christopher Faulete86bf652019-09-24 16:35:19 +02001654 double secs;
Christopher Fauletf959d082019-02-07 15:38:42 +01001655
1656 while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) {
1657 while (appctx->ctx.stats.px) {
1658 px = appctx->ctx.stats.px;
1659
1660 /* skip the disabled proxies, global frontend and non-networked ones */
1661 if (px->state == PR_STSTOPPED || px->uuid <= 0 || !(px->cap & PR_CAP_BE))
1662 goto next_px;
1663
1664 switch (appctx->st2) {
1665 case ST_F_STATUS:
1666 metric = mkf_u32(FO_STATUS, (px->lbprm.tot_weight > 0 || !px->srv) ? 1 : 0);
1667 break;
1668 case ST_F_SCUR:
1669 metric = mkf_u32(0, px->beconn);
1670 break;
1671 case ST_F_SMAX:
1672 metric = mkf_u32(FN_MAX, px->be_counters.conn_max);
1673 break;
1674 case ST_F_SLIM:
1675 metric = mkf_u32(FO_CONFIG|FN_LIMIT, px->fullconn);
1676 break;
1677 case ST_F_STOT:
1678 metric = mkf_u64(FN_COUNTER, px->be_counters.cum_conn);
1679 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001680 case ST_F_RATE_MAX:
1681 metric = mkf_u32(0, px->be_counters.sps_max);
1682 break;
1683 case ST_F_LASTSESS:
1684 metric = mkf_s32(FN_AGE, be_lastsession(px));
1685 break;
1686 case ST_F_QCUR:
1687 metric = mkf_u32(0, px->nbpend);
1688 break;
1689 case ST_F_QMAX:
1690 metric = mkf_u32(FN_MAX, px->be_counters.nbpend_max);
1691 break;
1692 case ST_F_CONNECT:
1693 metric = mkf_u64(FN_COUNTER, px->be_counters.connect);
1694 break;
1695 case ST_F_REUSE:
1696 metric = mkf_u64(FN_COUNTER, px->be_counters.reuse);
1697 break;
1698 case ST_F_BIN:
1699 metric = mkf_u64(FN_COUNTER, px->be_counters.bytes_in);
1700 break;
1701 case ST_F_BOUT:
1702 metric = mkf_u64(FN_COUNTER, px->be_counters.bytes_out);
1703 break;
1704 case ST_F_QTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001705 secs = (double)swrate_avg(px->be_counters.q_time, TIME_STATS_SAMPLES) / 1000.0;
1706 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001707 break;
1708 case ST_F_CTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001709 secs = (double)swrate_avg(px->be_counters.c_time, TIME_STATS_SAMPLES) / 1000.0;
1710 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001711 break;
1712 case ST_F_RTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001713 secs = (double)swrate_avg(px->be_counters.d_time, TIME_STATS_SAMPLES) / 1000.0;
1714 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001715 break;
1716 case ST_F_TTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001717 secs = (double)swrate_avg(px->be_counters.t_time, TIME_STATS_SAMPLES) / 1000.0;
1718 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001719 break;
Christopher Faulet5df597a2019-11-08 15:05:31 +01001720 case ST_F_QT_MAX:
1721 secs = (double)px->be_counters.qtime_max / 1000.0;
1722 metric = mkf_flt(FN_MAX, secs);
1723 break;
1724 case ST_F_CT_MAX:
1725 secs = (double)px->be_counters.ctime_max / 1000.0;
1726 metric = mkf_flt(FN_MAX, secs);
1727 break;
1728 case ST_F_RT_MAX:
1729 secs = (double)px->be_counters.dtime_max / 1000.0;
1730 metric = mkf_flt(FN_MAX, secs);
1731 break;
1732 case ST_F_TT_MAX:
1733 secs = (double)px->be_counters.ttime_max / 1000.0;
1734 metric = mkf_flt(FN_MAX, secs);
1735 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001736 case ST_F_DREQ:
1737 metric = mkf_u64(FN_COUNTER, px->be_counters.denied_req);
1738 break;
1739 case ST_F_DRESP:
1740 metric = mkf_u64(FN_COUNTER, px->be_counters.denied_resp);
1741 break;
1742 case ST_F_ECON:
1743 metric = mkf_u64(FN_COUNTER, px->be_counters.failed_conns);
1744 break;
1745 case ST_F_ERESP:
1746 metric = mkf_u64(FN_COUNTER, px->be_counters.failed_resp);
1747 break;
1748 case ST_F_WRETR:
1749 metric = mkf_u64(FN_COUNTER, px->be_counters.retries);
1750 break;
1751 case ST_F_WREDIS:
1752 metric = mkf_u64(FN_COUNTER, px->be_counters.redispatches);
1753 break;
1754 case ST_F_WREW:
1755 metric = mkf_u64(FN_COUNTER, px->be_counters.failed_rewrites);
1756 break;
1757 case ST_F_CLI_ABRT:
1758 metric = mkf_u64(FN_COUNTER, px->be_counters.cli_aborts);
1759 break;
1760 case ST_F_SRV_ABRT:
1761 metric = mkf_u64(FN_COUNTER, px->be_counters.srv_aborts);
1762 break;
1763 case ST_F_WEIGHT:
1764 weight = (px->lbprm.tot_weight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv;
1765 metric = mkf_u32(FN_AVG, weight);
1766 break;
1767 case ST_F_ACT:
1768 metric = mkf_u32(0, px->srv_act);
1769 break;
1770 case ST_F_BCK:
1771 metric = mkf_u32(0, px->srv_bck);
1772 break;
1773 case ST_F_CHKDOWN:
1774 metric = mkf_u64(FN_COUNTER, px->down_trans);
1775 break;
1776 case ST_F_LASTCHG:
1777 metric = mkf_u32(FN_AGE, now.tv_sec - px->last_change);
1778 break;
1779 case ST_F_DOWNTIME:
1780 metric = mkf_u32(FN_COUNTER, be_downtime(px));
1781 break;
1782 case ST_F_LBTOT:
1783 metric = mkf_u64(FN_COUNTER, px->be_counters.cum_lbconn);
1784 break;
1785 case ST_F_REQ_TOT:
1786 if (px->mode != PR_MODE_HTTP)
1787 goto next_px;
1788 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.cum_req);
1789 break;
1790 case ST_F_HRSP_1XX:
1791 if (px->mode != PR_MODE_HTTP)
1792 goto next_px;
1793 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[1]);
1794 break;
1795 case ST_F_HRSP_2XX:
1796 if (px->mode != PR_MODE_HTTP)
1797 goto next_px;
1798 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1799 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[2]);
1800 break;
1801 case ST_F_HRSP_3XX:
1802 if (px->mode != PR_MODE_HTTP)
1803 goto next_px;
1804 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1805 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[3]);
1806 break;
1807 case ST_F_HRSP_4XX:
1808 if (px->mode != PR_MODE_HTTP)
1809 goto next_px;
1810 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1811 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[4]);
1812 break;
1813 case ST_F_HRSP_5XX:
1814 if (px->mode != PR_MODE_HTTP)
1815 goto next_px;
1816 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1817 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[5]);
1818 break;
1819 case ST_F_HRSP_OTHER:
1820 if (px->mode != PR_MODE_HTTP)
1821 goto next_px;
1822 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
1823 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[0]);
1824 break;
1825 case ST_F_CACHE_LOOKUPS:
1826 if (px->mode != PR_MODE_HTTP)
1827 goto next_px;
1828 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.cache_lookups);
1829 break;
1830 case ST_F_CACHE_HITS:
1831 if (px->mode != PR_MODE_HTTP)
1832 goto next_px;
1833 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.cache_hits);
1834 break;
1835 case ST_F_COMP_IN:
1836 if (px->mode != PR_MODE_HTTP)
1837 goto next_px;
1838 metric = mkf_u64(FN_COUNTER, px->be_counters.comp_in);
1839 break;
1840 case ST_F_COMP_OUT:
1841 if (px->mode != PR_MODE_HTTP)
1842 goto next_px;
1843 metric = mkf_u64(FN_COUNTER, px->be_counters.comp_out);
1844 break;
1845 case ST_F_COMP_BYP:
1846 if (px->mode != PR_MODE_HTTP)
1847 goto next_px;
1848 metric = mkf_u64(FN_COUNTER, px->be_counters.comp_byp);
1849 break;
1850 case ST_F_COMP_RSP:
1851 if (px->mode != PR_MODE_HTTP)
1852 goto next_px;
1853 metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.comp_rsp);
1854 break;
1855
1856 default:
1857 goto next_metric;
1858 }
1859
1860 if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
1861 goto full;
1862 next_px:
1863 appctx->ctx.stats.px = px->next;
1864 }
1865 next_metric:
1866 appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
1867 appctx->ctx.stats.px = proxies_list;
1868 appctx->st2 = promex_back_metrics[appctx->st2];
1869 }
1870
1871 end:
Christopher Faulet0f58c0b2019-07-04 10:03:28 +02001872 if (out.len) {
1873 if (!htx_add_data_atonce(htx, out))
1874 return -1; /* Unexpected and unrecoverable error */
1875 channel_add_input(chn, out.len);
1876 }
Christopher Fauletf959d082019-02-07 15:38:42 +01001877 return ret;
1878 full:
1879 ret = 0;
1880 goto end;
1881}
1882
1883/* Dump servers metrics (prefixed by "haproxy_server_"). It returns 1 on sucess,
1884 * 0 if <htx> is full and -1 in case of any error. */
1885static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
1886{
1887 static struct ist prefix = IST("haproxy_server_");
1888 struct proxy *px;
1889 struct server *sv;
1890 struct field metric;
1891 struct channel *chn = si_ic(appctx->owner);
1892 struct ist out = ist2(trash.area, 0);
Christopher Faulet94d837e2019-07-03 11:43:17 +02001893 size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx));
Christopher Fauletf959d082019-02-07 15:38:42 +01001894 int ret = 1;
1895 uint32_t weight;
Christopher Faulete86bf652019-09-24 16:35:19 +02001896 double secs;
Christopher Fauletf959d082019-02-07 15:38:42 +01001897
1898 while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) {
1899 while (appctx->ctx.stats.px) {
1900 px = appctx->ctx.stats.px;
1901
1902 /* skip the disabled proxies, global frontend and non-networked ones */
1903 if (px->state == PR_STSTOPPED || px->uuid <= 0 || !(px->cap & PR_CAP_BE))
1904 goto next_px;
1905
1906 while (appctx->ctx.stats.sv) {
1907 sv = appctx->ctx.stats.sv;
1908
Christopher Faulete48e9962019-11-19 14:18:24 +01001909 if ((appctx->ctx.stats.flags & PROMEX_FL_NO_MAINT_SRV) && (sv->cur_admin & SRV_ADMF_MAINT))
1910 goto next_sv;
1911
Christopher Fauletf959d082019-02-07 15:38:42 +01001912 switch (appctx->st2) {
1913 case ST_F_STATUS:
1914 metric = mkf_u32(FO_STATUS, promex_srv_status(sv));
1915 break;
1916 case ST_F_SCUR:
1917 metric = mkf_u32(0, sv->cur_sess);
1918 break;
1919 case ST_F_SMAX:
1920 metric = mkf_u32(FN_MAX, sv->counters.cur_sess_max);
1921 break;
1922 case ST_F_SLIM:
1923 metric = mkf_u32(FO_CONFIG|FN_LIMIT, sv->maxconn);
1924 break;
1925 case ST_F_STOT:
1926 metric = mkf_u64(FN_COUNTER, sv->counters.cum_sess);
1927 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001928 case ST_F_RATE_MAX:
1929 metric = mkf_u32(FN_MAX, sv->counters.sps_max);
1930 break;
1931 case ST_F_LASTSESS:
1932 metric = mkf_s32(FN_AGE, srv_lastsession(sv));
1933 break;
1934 case ST_F_QCUR:
1935 metric = mkf_u32(0, sv->nbpend);
1936 break;
1937 case ST_F_QMAX:
1938 metric = mkf_u32(FN_MAX, sv->counters.nbpend_max);
1939 break;
1940 case ST_F_QLIMIT:
1941 metric = mkf_u32(FO_CONFIG|FS_SERVICE, sv->maxqueue);
1942 break;
1943 case ST_F_BIN:
1944 metric = mkf_u64(FN_COUNTER, sv->counters.bytes_in);
1945 break;
1946 case ST_F_BOUT:
1947 metric = mkf_u64(FN_COUNTER, sv->counters.bytes_out);
1948 break;
1949 case ST_F_QTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001950 secs = (double)swrate_avg(sv->counters.q_time, TIME_STATS_SAMPLES) / 1000.0;
1951 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001952 break;
1953 case ST_F_CTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001954 secs = (double)swrate_avg(sv->counters.c_time, TIME_STATS_SAMPLES) / 1000.0;
1955 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001956 break;
1957 case ST_F_RTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001958 secs = (double)swrate_avg(sv->counters.d_time, TIME_STATS_SAMPLES) / 1000.0;
1959 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001960 break;
1961 case ST_F_TTIME:
Christopher Faulete86bf652019-09-24 16:35:19 +02001962 secs = (double)swrate_avg(sv->counters.t_time, TIME_STATS_SAMPLES) / 1000.0;
1963 metric = mkf_flt(FN_AVG, secs);
Christopher Fauletf959d082019-02-07 15:38:42 +01001964 break;
Christopher Faulet5df597a2019-11-08 15:05:31 +01001965 case ST_F_QT_MAX:
1966 secs = (double)sv->counters.qtime_max / 1000.0;
1967 metric = mkf_flt(FN_MAX, secs);
1968 break;
1969 case ST_F_CT_MAX:
1970 secs = (double)sv->counters.ctime_max / 1000.0;
1971 metric = mkf_flt(FN_MAX, secs);
1972 break;
1973 case ST_F_RT_MAX:
1974 secs = (double)sv->counters.dtime_max / 1000.0;
1975 metric = mkf_flt(FN_MAX, secs);
1976 break;
1977 case ST_F_TT_MAX:
1978 secs = (double)sv->counters.ttime_max / 1000.0;
1979 metric = mkf_flt(FN_MAX, secs);
1980 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01001981 case ST_F_CONNECT:
1982 metric = mkf_u64(FN_COUNTER, sv->counters.connect);
1983 break;
1984 case ST_F_REUSE:
1985 metric = mkf_u64(FN_COUNTER, sv->counters.reuse);
1986 break;
1987 case ST_F_DRESP:
1988 metric = mkf_u64(FN_COUNTER, sv->counters.failed_secu);
1989 break;
1990 case ST_F_ECON:
1991 metric = mkf_u64(FN_COUNTER, sv->counters.failed_conns);
1992 break;
1993 case ST_F_ERESP:
1994 metric = mkf_u64(FN_COUNTER, sv->counters.failed_resp);
1995 break;
1996 case ST_F_WRETR:
1997 metric = mkf_u64(FN_COUNTER, sv->counters.retries);
1998 break;
1999 case ST_F_WREDIS:
2000 metric = mkf_u64(FN_COUNTER, sv->counters.redispatches);
2001 break;
2002 case ST_F_WREW:
2003 metric = mkf_u64(FN_COUNTER, sv->counters.failed_rewrites);
2004 break;
2005 case ST_F_CLI_ABRT:
2006 metric = mkf_u64(FN_COUNTER, sv->counters.cli_aborts);
2007 break;
2008 case ST_F_SRV_ABRT:
2009 metric = mkf_u64(FN_COUNTER, sv->counters.srv_aborts);
2010 break;
2011 case ST_F_WEIGHT:
2012 weight = (sv->cur_eweight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv;
2013 metric = mkf_u32(FN_AVG, weight);
2014 break;
Christopher Faulete019d182019-11-21 14:35:46 +01002015 case ST_F_CHECK_STATUS:
2016 if ((sv->check.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) != CHK_ST_ENABLED)
2017 goto next_sv;
2018 metric = mkf_u32(FN_OUTPUT, sv->check.status);
2019 break;
2020 case ST_F_CHECK_CODE:
2021 if ((sv->check.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) != CHK_ST_ENABLED)
2022 goto next_sv;
2023 metric = mkf_u32(FN_OUTPUT, (sv->check.status < HCHK_STATUS_L57DATA) ? 0 : sv->check.code);
2024 break;
Christopher Faulet4ab0efb2020-02-27 16:12:07 +01002025 case ST_F_CHECK_DURATION:
2026 if (sv->check.status < HCHK_STATUS_CHECKED)
2027 goto next_sv;
2028 secs = (double)sv->check.duration / 1000.0;
2029 metric = mkf_flt(FN_DURATION, secs);
2030 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01002031 case ST_F_CHKFAIL:
2032 metric = mkf_u64(FN_COUNTER, sv->counters.failed_checks);
2033 break;
2034 case ST_F_CHKDOWN:
2035 metric = mkf_u64(FN_COUNTER, sv->counters.down_trans);
2036 break;
2037 case ST_F_DOWNTIME:
2038 metric = mkf_u32(FN_COUNTER, srv_downtime(sv));
2039 break;
2040 case ST_F_LASTCHG:
2041 metric = mkf_u32(FN_AGE, now.tv_sec - sv->last_change);
2042 break;
2043 case ST_F_THROTTLE:
2044 metric = mkf_u32(FN_AVG, server_throttle_rate(sv));
2045 break;
2046 case ST_F_LBTOT:
2047 metric = mkf_u64(FN_COUNTER, sv->counters.cum_lbconn);
2048 break;
2049 case ST_F_HRSP_1XX:
2050 if (px->mode != PR_MODE_HTTP)
2051 goto next_px;
2052 metric = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[1]);
2053 break;
2054 case ST_F_HRSP_2XX:
2055 if (px->mode != PR_MODE_HTTP)
2056 goto next_px;
2057 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
2058 metric = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[2]);
2059 break;
2060 case ST_F_HRSP_3XX:
2061 if (px->mode != PR_MODE_HTTP)
2062 goto next_px;
2063 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
2064 metric = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[3]);
2065 break;
2066 case ST_F_HRSP_4XX:
2067 if (px->mode != PR_MODE_HTTP)
2068 goto next_px;
2069 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
2070 metric = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[4]);
2071 break;
2072 case ST_F_HRSP_5XX:
2073 if (px->mode != PR_MODE_HTTP)
2074 goto next_px;
2075 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
2076 metric = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[5]);
2077 break;
2078 case ST_F_HRSP_OTHER:
2079 if (px->mode != PR_MODE_HTTP)
2080 goto next_px;
2081 appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
2082 metric = mkf_u64(FN_COUNTER, sv->counters.p.http.rsp[0]);
2083 break;
Christopher Fauletbd767f72019-11-08 15:24:32 +01002084 case ST_F_SRV_ICUR:
2085 metric = mkf_u32(0, sv->curr_idle_conns);
2086 break;
2087 case ST_F_SRV_ILIM:
2088 metric = mkf_u32(FO_CONFIG|FN_LIMIT, (sv->max_idle_conns == -1) ? 0 : sv->max_idle_conns);
2089 break;
Christopher Fauletf959d082019-02-07 15:38:42 +01002090
2091 default:
2092 goto next_metric;
2093 }
2094
2095 if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
2096 goto full;
2097
Christopher Faulete48e9962019-11-19 14:18:24 +01002098 next_sv:
Christopher Fauletf959d082019-02-07 15:38:42 +01002099 appctx->ctx.stats.sv = sv->next;
2100 }
2101
2102 next_px:
2103 appctx->ctx.stats.px = px->next;
2104 appctx->ctx.stats.sv = (appctx->ctx.stats.px ? appctx->ctx.stats.px->srv : NULL);
2105 }
2106 next_metric:
2107 appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
2108 appctx->ctx.stats.px = proxies_list;
2109 appctx->ctx.stats.sv = (appctx->ctx.stats.px ? appctx->ctx.stats.px->srv : NULL);
2110 appctx->st2 = promex_srv_metrics[appctx->st2];
2111 }
2112
2113
2114 end:
Christopher Faulet0f58c0b2019-07-04 10:03:28 +02002115 if (out.len) {
2116 if (!htx_add_data_atonce(htx, out))
2117 return -1; /* Unexpected and unrecoverable error */
2118 channel_add_input(chn, out.len);
2119 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002120 return ret;
2121 full:
2122 ret = 0;
2123 goto end;
2124}
2125
2126/* Dump all metrics (global, frontends, backends and servers) depending on the
2127 * dumper state (appctx->st1). It returns 1 on success, 0 if <htx> is full and
2128 * -1 in case of any error. */
2129static int promex_dump_metrics(struct appctx *appctx, struct stream_interface *si, struct htx *htx)
2130{
2131 int ret;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002132 int flags = appctx->ctx.stats.flags;
Christopher Fauletf959d082019-02-07 15:38:42 +01002133
2134 switch (appctx->st1) {
2135 case PROMEX_DUMPER_INIT:
2136 appctx->ctx.stats.px = NULL;
2137 appctx->ctx.stats.sv = NULL;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002138 appctx->ctx.stats.flags = (flags|PROMEX_FL_METRIC_HDR|PROMEX_FL_INFO_METRIC);
Christopher Fauletf959d082019-02-07 15:38:42 +01002139 appctx->st2 = promex_global_metrics[INF_NAME];
2140 appctx->st1 = PROMEX_DUMPER_GLOBAL;
2141 /* fall through */
2142
2143 case PROMEX_DUMPER_GLOBAL:
Christopher Faulet32d634f2019-11-18 14:47:08 +01002144 if (appctx->ctx.stats.flags & PROMEX_FL_SCOPE_GLOBAL) {
2145 ret = promex_dump_global_metrics(appctx, htx);
2146 if (ret <= 0) {
2147 if (ret == -1)
2148 goto error;
2149 goto full;
2150 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002151 }
2152
2153 appctx->ctx.stats.px = proxies_list;
2154 appctx->ctx.stats.sv = NULL;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002155 appctx->ctx.stats.flags = (flags|PROMEX_FL_METRIC_HDR|PROMEX_FL_STATS_METRIC);
Christopher Fauletf959d082019-02-07 15:38:42 +01002156 appctx->st2 = promex_front_metrics[ST_F_PXNAME];
2157 appctx->st1 = PROMEX_DUMPER_FRONT;
2158 /* fall through */
2159
2160 case PROMEX_DUMPER_FRONT:
Christopher Faulet32d634f2019-11-18 14:47:08 +01002161 if (appctx->ctx.stats.flags & PROMEX_FL_SCOPE_FRONT) {
2162 ret = promex_dump_front_metrics(appctx, htx);
2163 if (ret <= 0) {
2164 if (ret == -1)
2165 goto error;
2166 goto full;
2167 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002168 }
2169
2170 appctx->ctx.stats.px = proxies_list;
2171 appctx->ctx.stats.sv = NULL;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002172 appctx->ctx.stats.flags = (flags|PROMEX_FL_METRIC_HDR|PROMEX_FL_STATS_METRIC);
Christopher Fauletf959d082019-02-07 15:38:42 +01002173 appctx->st2 = promex_back_metrics[ST_F_PXNAME];
2174 appctx->st1 = PROMEX_DUMPER_BACK;
2175 /* fall through */
2176
2177 case PROMEX_DUMPER_BACK:
Christopher Faulet32d634f2019-11-18 14:47:08 +01002178 if (appctx->ctx.stats.flags & PROMEX_FL_SCOPE_BACK) {
2179 ret = promex_dump_back_metrics(appctx, htx);
2180 if (ret <= 0) {
2181 if (ret == -1)
2182 goto error;
2183 goto full;
2184 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002185 }
2186
2187 appctx->ctx.stats.px = proxies_list;
2188 appctx->ctx.stats.sv = (appctx->ctx.stats.px ? appctx->ctx.stats.px->srv : NULL);
Christopher Faulet32d634f2019-11-18 14:47:08 +01002189 appctx->ctx.stats.flags = (flags|PROMEX_FL_METRIC_HDR|PROMEX_FL_STATS_METRIC);
Christopher Fauletf959d082019-02-07 15:38:42 +01002190 appctx->st2 = promex_srv_metrics[ST_F_PXNAME];
2191 appctx->st1 = PROMEX_DUMPER_SRV;
2192 /* fall through */
2193
2194 case PROMEX_DUMPER_SRV:
Christopher Faulet32d634f2019-11-18 14:47:08 +01002195 if (appctx->ctx.stats.flags & PROMEX_FL_SCOPE_SERVER) {
2196 ret = promex_dump_srv_metrics(appctx, htx);
2197 if (ret <= 0) {
2198 if (ret == -1)
2199 goto error;
2200 goto full;
2201 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002202 }
2203
2204 appctx->ctx.stats.px = NULL;
2205 appctx->ctx.stats.sv = NULL;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002206 appctx->ctx.stats.flags = flags;
Christopher Fauletf959d082019-02-07 15:38:42 +01002207 appctx->st2 = 0;
2208 appctx->st1 = PROMEX_DUMPER_DONE;
2209 /* fall through */
2210
2211 case PROMEX_DUMPER_DONE:
2212 default:
2213 break;
2214 }
2215
2216 return 1;
2217
2218 full:
2219 si_rx_room_blk(si);
2220 return 0;
2221 error:
2222 /* unrecoverable error */
2223 appctx->ctx.stats.px = NULL;
2224 appctx->ctx.stats.sv = NULL;
2225 appctx->ctx.stats.flags = 0;
2226 appctx->st2 = 0;
2227 appctx->st1 = PROMEX_DUMPER_DONE;
2228 return -1;
2229}
2230
Christopher Faulet32d634f2019-11-18 14:47:08 +01002231/* Parse the query stirng of request URI to filter the metrics. It returns 1 on
2232 * success and -1 on error. */
2233static int promex_parse_uri(struct appctx *appctx, struct stream_interface *si)
2234{
2235 struct channel *req = si_oc(si);
2236 struct channel *res = si_ic(si);
2237 struct htx *req_htx, *res_htx;
2238 struct htx_sl *sl;
William Dauchy200c6212019-11-26 12:56:26 +01002239 char *p, *key, *value;
2240 const char *end;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002241 struct buffer *err;
2242 int default_scopes = PROMEX_FL_SCOPE_ALL;
2243 int len;
2244
2245 /* Get the query-string */
2246 req_htx = htxbuf(&req->buf);
2247 sl = http_get_stline(req_htx);
2248 if (!sl)
2249 goto error;
2250 p = http_find_param_list(HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl), '?');
2251 if (!p)
2252 goto end;
2253 end = HTX_SL_REQ_UPTR(sl) + HTX_SL_REQ_ULEN(sl);
Christopher Faulet32d634f2019-11-18 14:47:08 +01002254
William Dauchy200c6212019-11-26 12:56:26 +01002255 /* copy the query-string */
2256 len = end - p;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002257 chunk_reset(&trash);
2258 memcpy(trash.area, p, len);
2259 trash.area[len] = 0;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002260 p = trash.area;
William Dauchy200c6212019-11-26 12:56:26 +01002261 end = trash.area + len;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002262
2263 /* Parse the query-string */
William Dauchy200c6212019-11-26 12:56:26 +01002264 while (p < end && *p && *p != '#') {
2265 value = NULL;
2266
2267 /* decode parameter name */
2268 key = p;
2269 while (p < end && *p != '=' && *p != '&' && *p != '#')
Christopher Faulet32d634f2019-11-18 14:47:08 +01002270 ++p;
William Dauchy200c6212019-11-26 12:56:26 +01002271 /* found a value */
2272 if (*p == '=') {
2273 *(p++) = 0;
2274 value = p;
2275 }
2276 else if (*p == '&')
2277 *(p++) = 0;
2278 else if (*p == '#')
2279 *p = 0;
2280 len = url_decode(key);
2281 if (len == -1)
2282 goto error;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002283
William Dauchy200c6212019-11-26 12:56:26 +01002284 /* decode value */
2285 if (value) {
2286 while (p < end && *p != '=' && *p != '&' && *p != '#')
2287 ++p;
2288 if (*p == '=')
2289 goto error;
2290 if (*p == '&')
2291 *(p++) = 0;
2292 else if (*p == '#')
2293 *p = 0;
2294 len = url_decode(value);
2295 if (len == -1)
2296 goto error;
2297 }
2298
2299 if (!strcmp(key, "scope")) {
2300 default_scopes = 0; /* at least a scope defined, unset default scopes */
2301 if (!value)
2302 goto error;
2303 else if (*value == 0)
Christopher Faulet32d634f2019-11-18 14:47:08 +01002304 appctx->ctx.stats.flags &= ~PROMEX_FL_SCOPE_ALL;
William Dauchy200c6212019-11-26 12:56:26 +01002305 else if (*value == '*')
Christopher Faulet32d634f2019-11-18 14:47:08 +01002306 appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_ALL;
William Dauchy200c6212019-11-26 12:56:26 +01002307 else if (!strcmp(value, "global"))
2308 appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_GLOBAL;
2309 else if (!strcmp(value, "server"))
2310 appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_SERVER;
2311 else if (!strcmp(value, "backend"))
Christopher Faulet32d634f2019-11-18 14:47:08 +01002312 appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_BACK;
William Dauchy200c6212019-11-26 12:56:26 +01002313 else if (!strcmp(value, "frontend"))
Christopher Faulet32d634f2019-11-18 14:47:08 +01002314 appctx->ctx.stats.flags |= PROMEX_FL_SCOPE_FRONT;
2315 else
2316 goto error;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002317 }
William Dauchy200c6212019-11-26 12:56:26 +01002318 else if (!strcmp(key, "no-maint"))
Christopher Faulete48e9962019-11-19 14:18:24 +01002319 appctx->ctx.stats.flags |= PROMEX_FL_NO_MAINT_SRV;
Christopher Faulet32d634f2019-11-18 14:47:08 +01002320 }
2321
2322 end:
2323 appctx->ctx.stats.flags |= default_scopes;
2324 return 1;
2325
2326 error:
Christopher Faulet3a00e5f2019-11-27 11:22:37 +01002327 err = &htx_err_chunks[HTTP_ERR_400];
Christopher Faulet32d634f2019-11-18 14:47:08 +01002328 channel_erase(res);
2329 res->buf.data = b_data(err);
2330 memcpy(res->buf.area, b_head(err), b_data(err));
2331 res_htx = htx_from_buf(&res->buf);
2332 channel_add_input(res, res_htx->data);
2333 appctx->st0 = PROMEX_ST_END;
2334 return -1;
2335}
2336
Christopher Fauletf959d082019-02-07 15:38:42 +01002337/* Send HTTP headers of the response. It returns 1 on success and 0 if <htx> is
2338 * full. */
2339static int promex_send_headers(struct appctx *appctx, struct stream_interface *si, struct htx *htx)
2340{
Christopher Faulet9744f7c2019-03-27 15:48:53 +01002341 struct channel *chn = si_ic(appctx->owner);
Christopher Fauletf959d082019-02-07 15:38:42 +01002342 struct htx_sl *sl;
2343 unsigned int flags;
2344
2345 flags = (HTX_SL_F_IS_RESP|HTX_SL_F_VER_11|HTX_SL_F_XFER_ENC|HTX_SL_F_XFER_LEN|HTX_SL_F_CHNK);
2346 sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags, ist("HTTP/1.1"), ist("200"), ist("OK"));
2347 if (!sl)
2348 goto full;
2349 sl->info.res.status = 200;
2350 if (!htx_add_header(htx, ist("Cache-Control"), ist("no-cache")) ||
2351 !htx_add_header(htx, ist("Connection"), ist("close")) ||
2352 !htx_add_header(htx, ist("Content-Type"), ist("text/plain; version=0.0.4")) ||
2353 !htx_add_header(htx, ist("Transfer-Encoding"), ist("chunked")) ||
2354 !htx_add_endof(htx, HTX_BLK_EOH))
2355 goto full;
2356
Christopher Faulet9744f7c2019-03-27 15:48:53 +01002357 channel_add_input(chn, htx->data);
Christopher Fauletf959d082019-02-07 15:38:42 +01002358 return 1;
2359 full:
2360 htx_reset(htx);
2361 si_rx_room_blk(si);
2362 return 0;
2363}
2364
2365/* The function returns 1 if the initialisation is complete, 0 if
2366 * an errors occurs and -1 if more data are required for initializing
2367 * the applet.
2368 */
2369static int promex_appctx_init(struct appctx *appctx, struct proxy *px, struct stream *strm)
2370{
2371 appctx->st0 = PROMEX_ST_INIT;
2372 return 1;
2373}
2374
2375/* The main I/O handler for the promex applet. */
2376static void promex_appctx_handle_io(struct appctx *appctx)
2377{
2378 struct stream_interface *si = appctx->owner;
2379 struct stream *s = si_strm(si);
2380 struct channel *req = si_oc(si);
2381 struct channel *res = si_ic(si);
2382 struct htx *req_htx, *res_htx;
2383 int ret;
2384
2385 res_htx = htx_from_buf(&res->buf);
Christopher Fauletf959d082019-02-07 15:38:42 +01002386 if (unlikely(si->state == SI_ST_DIS || si->state == SI_ST_CLO))
2387 goto out;
2388
2389 /* Check if the input buffer is avalaible. */
2390 if (!b_size(&res->buf)) {
2391 si_rx_room_blk(si);
2392 goto out;
2393 }
2394
2395 switch (appctx->st0) {
2396 case PROMEX_ST_INIT:
Christopher Faulet32d634f2019-11-18 14:47:08 +01002397 ret = promex_parse_uri(appctx, si);
2398 if (ret <= 0) {
2399 if (ret == -1)
2400 goto error;
2401 goto out;
2402 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002403 appctx->st0 = PROMEX_ST_HEAD;
2404 appctx->st1 = PROMEX_DUMPER_INIT;
2405 /* fall through */
2406
2407 case PROMEX_ST_HEAD:
2408 if (!promex_send_headers(appctx, si, res_htx))
2409 goto out;
2410 appctx->st0 = ((s->txn->meth == HTTP_METH_HEAD) ? PROMEX_ST_DONE : PROMEX_ST_DUMP);
2411 /* fall through */
2412
2413 case PROMEX_ST_DUMP:
2414 ret = promex_dump_metrics(appctx, si, res_htx);
2415 if (ret <= 0) {
2416 if (ret == -1)
2417 goto error;
2418 goto out;
2419 }
2420 appctx->st0 = PROMEX_ST_DONE;
2421 /* fall through */
2422
2423 case PROMEX_ST_DONE:
Christopher Faulet54b5e212019-06-04 10:08:28 +02002424 /* Don't add TLR because mux-h1 will take care of it */
Christopher Fauletf959d082019-02-07 15:38:42 +01002425 if (!htx_add_endof(res_htx, HTX_BLK_EOM)) {
2426 si_rx_room_blk(si);
2427 goto out;
2428 }
Christopher Faulet9744f7c2019-03-27 15:48:53 +01002429 channel_add_input(res, 1);
2430 appctx->st0 = PROMEX_ST_END;
2431 /* fall through */
Christopher Fauletf959d082019-02-07 15:38:42 +01002432
Christopher Faulet9744f7c2019-03-27 15:48:53 +01002433 case PROMEX_ST_END:
2434 if (!(res->flags & CF_SHUTR)) {
2435 res->flags |= CF_READ_NULL;
2436 si_shutr(si);
2437 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002438 }
2439
Christopher Fauletf959d082019-02-07 15:38:42 +01002440 out:
2441 htx_to_buf(res_htx, &res->buf);
Christopher Faulet9744f7c2019-03-27 15:48:53 +01002442
2443 /* eat the whole request */
2444 if (co_data(req)) {
2445 req_htx = htx_from_buf(&req->buf);
2446 co_htx_skip(req, req_htx, co_data(req));
2447 }
Christopher Fauletf959d082019-02-07 15:38:42 +01002448 return;
2449
2450 error:
2451 res->flags |= CF_READ_NULL;
2452 si_shutr(si);
2453 si_shutw(si);
2454}
2455
2456struct applet promex_applet = {
2457 .obj_type = OBJ_TYPE_APPLET,
2458 .name = "<PROMEX>", /* used for logging */
2459 .init = promex_appctx_init,
2460 .fct = promex_appctx_handle_io,
2461};
2462
2463static enum act_parse_ret service_parse_prometheus_exporter(const char **args, int *cur_arg, struct proxy *px,
2464 struct act_rule *rule, char **err)
2465{
2466 /* Prometheus exporter service is only available on "http-request" rulesets */
2467 if (rule->from != ACT_F_HTTP_REQ) {
2468 memprintf(err, "Prometheus exporter service only available on 'http-request' rulesets");
2469 return ACT_RET_PRS_ERR;
2470 }
2471 if (!(px->options2 & PR_O2_USE_HTX)) {
2472 memprintf(err, "Prometheus exporter service only available for HTX proxies");
2473 return ACT_RET_PRS_ERR;
2474 }
2475
2476 /* Add applet pointer in the rule. */
2477 rule->applet = promex_applet;
2478
2479 return ACT_RET_PRS_OK;
2480}
2481static void promex_register_build_options(void)
2482{
2483 char *ptr = NULL;
2484
2485 memprintf(&ptr, "Built with the Prometheus exporter as a service");
2486 hap_register_build_opts(ptr, 1);
2487}
2488
2489
2490static struct action_kw_list service_actions = { ILH, {
2491 { "prometheus-exporter", service_parse_prometheus_exporter },
2492 { /* END */ }
2493}};
2494
2495INITCALL1(STG_REGISTER, service_keywords_register, &service_actions);
2496INITCALL0(STG_REGISTER, promex_register_build_options);