blob: c3b9fc8fc7a0606dc9ea502a65728b7726b32a20 [file] [log] [blame]
Willy Tarreau91861262007-10-17 17:06:05 +02001/*
William Lallemand9ed62032016-11-21 17:49:11 +01002 * include/types/stats.h
3 * This file provides structures and types for stats.
Willy Tarreaueb472682010-05-28 18:46:57 +02004 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation, version 2.1
8 * exclusively.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
Willy Tarreau91861262007-10-17 17:06:05 +020019
William Lallemand9ed62032016-11-21 17:49:11 +010020#ifndef _TYPES_STATS_H
21#define _TYPES_STATS_H
Willy Tarreau91861262007-10-17 17:06:05 +020022
Willy Tarreau295a8372011-03-10 11:25:07 +010023/* Flags for applet.ctx.stats.flags */
Willy Tarreau354898b2012-12-23 18:15:23 +010024#define STAT_FMT_HTML 0x00000001 /* dump the stats in HTML format */
Willy Tarreaucb809122016-01-11 20:08:42 +010025#define STAT_FMT_TYPED 0x00000002 /* use the typed output format */
Simon Horman05ee2132017-01-04 09:37:25 +010026#define STAT_FMT_JSON 0x00000004 /* dump the stats in JSON format */
Willy Tarreau39f7e6d2008-03-17 21:38:24 +010027#define STAT_HIDE_DOWN 0x00000008 /* hide 'down' servers in the stats page */
28#define STAT_NO_REFRESH 0x00000010 /* do not automatically refresh the stats page */
Cyril Bonté474be412010-10-12 00:14:36 +020029#define STAT_ADMIN 0x00000020 /* indicate a stats admin level */
Willy Tarreauaf3cf702014-04-22 22:19:53 +020030#define STAT_CHUNKED 0x00000040 /* use chunked encoding (HTTP/1.1) */
Willy Tarreau39f7e6d2008-03-17 21:38:24 +010031#define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */
Simon Horman05ee2132017-01-04 09:37:25 +010032#define STAT_STARTED 0x01000000 /* some output has occurred */
Willy Tarreau55bb8452007-10-17 18:44:57 +020033
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010034#define STATS_TYPE_FE 0
35#define STATS_TYPE_BE 1
36#define STATS_TYPE_SV 2
Krzysztof Piotr Oledzkiaeebf9b2009-10-04 15:43:17 +020037#define STATS_TYPE_SO 3
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010038
Willy Tarreau96d44912013-11-22 12:25:24 +010039/* HTTP stats : applet.st0 */
40enum {
41 STAT_HTTP_DONE = 0, /* finished */
Willy Tarreau347a35d2013-11-22 17:51:09 +010042 STAT_HTTP_HEAD, /* send headers before dump */
Willy Tarreau96d44912013-11-22 12:25:24 +010043 STAT_HTTP_DUMP, /* dumping stats */
Willy Tarreau347a35d2013-11-22 17:51:09 +010044 STAT_HTTP_POST, /* waiting post data */
45 STAT_HTTP_LAST, /* sending last chunk of response */
Willy Tarreau96d44912013-11-22 12:25:24 +010046};
47
de Lafond Guillaume88c278f2013-04-15 19:27:10 +020048/* HTML form to limit output scope */
49#define STAT_SCOPE_TXT_MAXLEN 20 /* max len for scope substring */
50#define STAT_SCOPE_INPUT_NAME "scope" /* pattern form scope name <input> in html form */
51#define STAT_SCOPE_PATTERN "?" STAT_SCOPE_INPUT_NAME "="
52
William Lallemand9ed62032016-11-21 17:49:11 +010053/* Actions available for the stats admin forms */
54enum {
55 ST_ADM_ACTION_NONE = 0,
Thierry Fournier31e64ca2016-03-23 16:25:49 +010056
William Lallemand9ed62032016-11-21 17:49:11 +010057 /* enable/disable health checks */
58 ST_ADM_ACTION_DHLTH,
59 ST_ADM_ACTION_EHLTH,
60
61 /* force health check status */
62 ST_ADM_ACTION_HRUNN,
63 ST_ADM_ACTION_HNOLB,
64 ST_ADM_ACTION_HDOWN,
65
66 /* enable/disable agent checks */
67 ST_ADM_ACTION_DAGENT,
68 ST_ADM_ACTION_EAGENT,
69
70 /* force agent check status */
71 ST_ADM_ACTION_ARUNN,
72 ST_ADM_ACTION_ADOWN,
73
74 /* set admin state */
75 ST_ADM_ACTION_READY,
76 ST_ADM_ACTION_DRAIN,
77 ST_ADM_ACTION_MAINT,
78 ST_ADM_ACTION_SHUTDOWN,
79 /* these are the ancient actions, still available for compatibility */
80 ST_ADM_ACTION_DISABLE,
81 ST_ADM_ACTION_ENABLE,
82 ST_ADM_ACTION_STOP,
83 ST_ADM_ACTION_START,
Thierry Fournier31e64ca2016-03-23 16:25:49 +010084};
85
Thierry Fournier31e64ca2016-03-23 16:25:49 +010086
William Lallemand9ed62032016-11-21 17:49:11 +010087/* data transmission states for the stats responses */
88enum {
89 STAT_ST_INIT = 0,
90 STAT_ST_HEAD,
91 STAT_ST_INFO,
92 STAT_ST_LIST,
93 STAT_ST_END,
94 STAT_ST_FIN,
Thierry Fournier31e64ca2016-03-23 16:25:49 +010095};
96
William Lallemand9ed62032016-11-21 17:49:11 +010097/* data transmission states for the stats responses inside a proxy */
98enum {
99 STAT_PX_ST_INIT = 0,
100 STAT_PX_ST_TH,
101 STAT_PX_ST_FE,
102 STAT_PX_ST_LI,
103 STAT_PX_ST_SV,
104 STAT_PX_ST_BE,
105 STAT_PX_ST_END,
106 STAT_PX_ST_FIN,
107};
108
Willy Tarreau8e62c052016-01-04 17:23:25 +0100109/* This level of detail is needed to let the stats consumer know how to
110 * aggregate them (eg: between processes or cluster nodes). Only a few
111 * combinations are actually in use, though the mechanism tends to make
112 * this easy to extend to future uses.
113 *
114 * Each reported stats element is typed based on 4 dimensions :
115 * - the field format : it indicates the validity range of the reported value,
116 * its limits and how to parse it. 6 types are currently supported :
117 * empty, signed 32-bit integer, unsigned 32-bit integer, signed 64-bit
118 * integer, unsigned 64-bit integer, string
119 *
120 * - the field origin : how was the value retrieved and what it depends on.
121 * 5 origins are currently defined : product (eg: haproxy version or
122 * release date), configuration (eg: a configured limit), key (identifier
123 * used to group values at a certain level), metric (a measure of something),
124 * status (something discrete which by definition cannot be averaged nor
125 * aggregated, such as "listening" versus "full").
126 *
127 * - the field nature : what does the data represent, implying how to aggregate
128 * it. At least 9 different natures are expected : counter (an increasing
129 * positive counter that may wrap when its type is overflown such as a byte
130 * counter), gauge (a measure at any instant that may vary, such as a
131 * concurrent connection count), a limit (eg: maximum acceptable concurrent
132 * connections), a minimum (eg: minimum free memory over a period), a
133 * maximum (eg: highest queue length over a period), an event rate (eg:
134 * incoming connections per second), a duration that is often aggregated by
135 * taking the max (eg: service uptime), an age that generally reports the
136 * last time an event appeared and which generally is aggregated by taking
137 * the most recent event hence the smallest one, the time which reports a
138 * discrete instant and cannot obviously be averaged either, a name which
139 * will generally be the name of an entity (such as a server name or cookie
140 * name), an output which is mostly used for various unsafe strings that are
141 * retrieved (eg: last check output, product name, description, etc), and an
142 * average which indicates that the value is relative and meant to be averaged
143 * between all nodes (eg: response time, throttling, etc).
144 *
145 * - the field scope : if the value is shared with other elements, which ones
146 * are expected to report the same value. The first scope with the least
147 * share is the process (most common one) where all data are only relevant
148 * to the process being consulted. The next one is the service, which is
149 * valid for all processes launched together (eg: shared SSL cache usage
150 * among processes). The next one is the system (such as the OS version)
151 * and which will report the same information for all instances running on
152 * the same node. The next one is the cluster, which indicates that the
153 * information are shared with other nodes being part of a same cluster.
154 * Stick-tables may carry such cluster-wide information. Larger scopes may
155 * be added in the future such as datacenter, country, continent, planet,
156 * galaxy, universe, etc.
157 *
158 * All these information will be encoded in the field as a bit field so that
159 * it is easy to pass composite values by simply ORing elements above, and
160 * to ease the definition of a few field types for the most common field
161 * combinations.
162 *
163 * The enums try to be arranged so that most likely characteristics are
164 * assigned the value zero, making it easier to add new fields.
165 *
166 * Field format has precedence over the other parts of the type. Please avoid
167 * declaring extra formats unless absolutely needed. The first one, FF_EMPTY,
168 * must absolutely have value zero so that it is what is returned after a
169 * memset(0). Furthermore, the producer is responsible for ensuring that when
170 * this format is set, all other bits of the type as well as the values in the
171 * union only contain zeroes. This makes it easier for the consumer to use the
172 * values as the expected type.
173 */
174
175enum field_format {
176 FF_EMPTY = 0x00000000,
177 FF_S32 = 0x00000001,
178 FF_U32 = 0x00000002,
179 FF_S64 = 0x00000003,
180 FF_U64 = 0x00000004,
181 FF_STR = 0x00000005,
182 FF_MASK = 0x000000FF,
183};
184
185enum field_origin {
186 FO_METRIC = 0x00000000,
187 FO_STATUS = 0x00000100,
188 FO_KEY = 0x00000200,
189 FO_CONFIG = 0x00000300,
190 FO_PRODUCT = 0x00000400,
191 FO_MASK = 0x0000FF00,
192};
193
194enum field_nature {
195 FN_GAUGE = 0x00000000,
196 FN_LIMIT = 0x00010000,
197 FN_MIN = 0x00020000,
198 FN_MAX = 0x00030000,
199 FN_RATE = 0x00040000,
200 FN_COUNTER = 0x00050000,
201 FN_DURATION = 0x00060000,
202 FN_AGE = 0x00070000,
203 FN_TIME = 0x00080000,
204 FN_NAME = 0x00090000,
205 FN_OUTPUT = 0x000A0000,
206 FN_AVG = 0x000B0000,
207 FN_MASK = 0x00FF0000,
208};
209
210enum field_scope {
211 FS_PROCESS = 0x00000000,
212 FS_SERVICE = 0x01000000,
213 FS_SYSTEM = 0x02000000,
214 FS_CLUSTER = 0x03000000,
215 FS_MASK = 0xFF000000,
216};
217
Simon Horman6f6bb382017-01-04 09:37:26 +0100218/* Please consider updating stats_dump_fields_*(),
219 * stats_dump_.*_info_fields() and stats_*_schema()
220 * when modifying struct field or related enums.
Simon Horman05ee2132017-01-04 09:37:25 +0100221 */
Willy Tarreau8e62c052016-01-04 17:23:25 +0100222struct field {
223 uint32_t type;
224 union {
225 int32_t s32; /* FF_S32 */
226 uint32_t u32; /* FF_U32 */
227 int64_t s64; /* FF_S64 */
228 uint64_t u64; /* FF_U64 */
229 const char *str; /* FF_STR */
230 } u;
231};
232
Willy Tarreau0baac8c2016-11-22 16:36:53 +0100233/* Show Info fields for CLI output. For any field added here, please add the text
234 * representation in the info_field_names array below. Please only append at the end,
235 * before the INF_TOTAL_FIELDS entry, and never insert anything in the middle
236 * nor at the beginning.
237 */
238enum info_field {
239 INF_NAME,
240 INF_VERSION,
241 INF_RELEASE_DATE,
Yves Lafon95317282018-02-26 11:10:37 +0100242 INF_NBTHREAD,
Willy Tarreau0baac8c2016-11-22 16:36:53 +0100243 INF_NBPROC,
244 INF_PROCESS_NUM,
245 INF_PID,
246 INF_UPTIME,
247 INF_UPTIME_SEC,
248 INF_MEMMAX_MB,
249 INF_POOL_ALLOC_MB,
250 INF_POOL_USED_MB,
251 INF_POOL_FAILED,
252 INF_ULIMIT_N,
253 INF_MAXSOCK,
254 INF_MAXCONN,
255 INF_HARD_MAXCONN,
256 INF_CURR_CONN,
257 INF_CUM_CONN,
258 INF_CUM_REQ,
259 INF_MAX_SSL_CONNS,
260 INF_CURR_SSL_CONNS,
261 INF_CUM_SSL_CONNS,
262 INF_MAXPIPES,
263 INF_PIPES_USED,
264 INF_PIPES_FREE,
265 INF_CONN_RATE,
266 INF_CONN_RATE_LIMIT,
267 INF_MAX_CONN_RATE,
268 INF_SESS_RATE,
269 INF_SESS_RATE_LIMIT,
270 INF_MAX_SESS_RATE,
271 INF_SSL_RATE,
272 INF_SSL_RATE_LIMIT,
273 INF_MAX_SSL_RATE,
274 INF_SSL_FRONTEND_KEY_RATE,
275 INF_SSL_FRONTEND_MAX_KEY_RATE,
276 INF_SSL_FRONTEND_SESSION_REUSE_PCT,
277 INF_SSL_BACKEND_KEY_RATE,
278 INF_SSL_BACKEND_MAX_KEY_RATE,
279 INF_SSL_CACHE_LOOKUPS,
280 INF_SSL_CACHE_MISSES,
281 INF_COMPRESS_BPS_IN,
282 INF_COMPRESS_BPS_OUT,
283 INF_COMPRESS_BPS_RATE_LIM,
284 INF_ZLIB_MEM_USAGE,
285 INF_MAX_ZLIB_MEM_USAGE,
286 INF_TASKS,
287 INF_RUN_QUEUE,
288 INF_IDLE_PCT,
289 INF_NODE,
290 INF_DESCRIPTION,
Willy Tarreau00098ea2018-11-05 14:38:13 +0100291 INF_STOPPING,
292 INF_JOBS,
William Lallemanda7199262018-11-16 16:57:20 +0100293 INF_UNSTOPPABLE_JOBS,
Willy Tarreau00098ea2018-11-05 14:38:13 +0100294 INF_LISTENERS,
Willy Tarreau199ad242018-11-05 16:31:22 +0100295 INF_ACTIVE_PEERS,
Willy Tarreau2d372c22018-11-05 17:12:27 +0100296 INF_CONNECTED_PEERS,
Willy Tarreau13ef7732018-11-12 07:25:28 +0100297 INF_DROPPED_LOGS,
Willy Tarreaubeb859a2018-11-22 18:07:59 +0100298 INF_BUSY_POLLING,
Willy Tarreau0baac8c2016-11-22 16:36:53 +0100299
300 /* must always be the last one */
301 INF_TOTAL_FIELDS
302};
303
304
William Lallemand9ed62032016-11-21 17:49:11 +0100305/* Stats fields for CSV output. For any field added here, please add the text
306 * representation in the stat_field_names array below. Please only append at the end,
307 * before the ST_F_TOTAL_FIELDS entry, and never insert anything in the middle
308 * nor at the beginning.
Thierry Fournier31e64ca2016-03-23 16:25:49 +0100309 */
William Lallemand9ed62032016-11-21 17:49:11 +0100310enum stat_field {
311 ST_F_PXNAME,
312 ST_F_SVNAME,
313 ST_F_QCUR,
314 ST_F_QMAX,
315 ST_F_SCUR,
316 ST_F_SMAX,
317 ST_F_SLIM,
318 ST_F_STOT,
319 ST_F_BIN ,
320 ST_F_BOUT,
321 ST_F_DREQ,
322 ST_F_DRESP,
323 ST_F_EREQ,
324 ST_F_ECON,
325 ST_F_ERESP,
326 ST_F_WRETR,
327 ST_F_WREDIS,
328 ST_F_STATUS,
329 ST_F_WEIGHT,
330 ST_F_ACT,
331 ST_F_BCK,
332 ST_F_CHKFAIL,
333 ST_F_CHKDOWN,
334 ST_F_LASTCHG,
335 ST_F_DOWNTIME,
336 ST_F_QLIMIT,
337 ST_F_PID,
338 ST_F_IID,
339 ST_F_SID,
340 ST_F_THROTTLE,
341 ST_F_LBTOT,
342 ST_F_TRACKED,
343 ST_F_TYPE,
344 ST_F_RATE,
345 ST_F_RATE_LIM,
346 ST_F_RATE_MAX,
347 ST_F_CHECK_STATUS,
348 ST_F_CHECK_CODE,
349 ST_F_CHECK_DURATION,
350 ST_F_HRSP_1XX,
351 ST_F_HRSP_2XX,
352 ST_F_HRSP_3XX,
353 ST_F_HRSP_4XX,
354 ST_F_HRSP_5XX,
355 ST_F_HRSP_OTHER,
356 ST_F_HANAFAIL,
357 ST_F_REQ_RATE,
358 ST_F_REQ_RATE_MAX,
359 ST_F_REQ_TOT,
360 ST_F_CLI_ABRT,
361 ST_F_SRV_ABRT,
362 ST_F_COMP_IN,
363 ST_F_COMP_OUT,
364 ST_F_COMP_BYP,
365 ST_F_COMP_RSP,
366 ST_F_LASTSESS,
367 ST_F_LAST_CHK,
368 ST_F_LAST_AGT,
369 ST_F_QTIME,
370 ST_F_CTIME,
371 ST_F_RTIME,
372 ST_F_TTIME,
373 ST_F_AGENT_STATUS,
374 ST_F_AGENT_CODE,
375 ST_F_AGENT_DURATION,
376 ST_F_CHECK_DESC,
377 ST_F_AGENT_DESC,
378 ST_F_CHECK_RISE,
379 ST_F_CHECK_FALL,
380 ST_F_CHECK_HEALTH,
381 ST_F_AGENT_RISE,
382 ST_F_AGENT_FALL,
383 ST_F_AGENT_HEALTH,
384 ST_F_ADDR,
385 ST_F_COOKIE,
386 ST_F_MODE,
387 ST_F_ALGO,
388 ST_F_CONN_RATE,
389 ST_F_CONN_RATE_MAX,
390 ST_F_CONN_TOT,
391 ST_F_INTERCEPTED,
392 ST_F_DCON,
393 ST_F_DSES,
Tim Duesterhus3fd19732018-05-27 20:35:08 +0200394 ST_F_WREW,
Willy Tarreauf1573842018-12-14 11:35:36 +0100395 ST_F_CONNECT,
396 ST_F_REUSE,
William Lallemand1e08cd82016-10-13 17:57:55 +0200397
William Lallemand9ed62032016-11-21 17:49:11 +0100398 /* must always be the last one */
399 ST_F_TOTAL_FIELDS
William Lallemand1e08cd82016-10-13 17:57:55 +0200400};
401
William Lallemand74c24fb2016-11-21 17:18:36 +0100402
William Lallemand9ed62032016-11-21 17:49:11 +0100403#endif /* _TYPES_STATS_H */