blob: dd52bba10947f550f615c97138f657bb7cd75ccc [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 */
Willy Tarreau39f7e6d2008-03-17 21:38:24 +010026#define STAT_HIDE_DOWN 0x00000008 /* hide 'down' servers in the stats page */
27#define STAT_NO_REFRESH 0x00000010 /* do not automatically refresh the stats page */
Cyril Bonté474be412010-10-12 00:14:36 +020028#define STAT_ADMIN 0x00000020 /* indicate a stats admin level */
Willy Tarreauaf3cf702014-04-22 22:19:53 +020029#define STAT_CHUNKED 0x00000040 /* use chunked encoding (HTTP/1.1) */
Willy Tarreau39f7e6d2008-03-17 21:38:24 +010030#define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */
Willy Tarreau55bb8452007-10-17 18:44:57 +020031
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010032#define STATS_TYPE_FE 0
33#define STATS_TYPE_BE 1
34#define STATS_TYPE_SV 2
Krzysztof Piotr Oledzkiaeebf9b2009-10-04 15:43:17 +020035#define STATS_TYPE_SO 3
Krzysztof Piotr Oledzki2c6962c2008-03-02 02:42:14 +010036
Willy Tarreau96d44912013-11-22 12:25:24 +010037/* HTTP stats : applet.st0 */
38enum {
39 STAT_HTTP_DONE = 0, /* finished */
Willy Tarreau347a35d2013-11-22 17:51:09 +010040 STAT_HTTP_HEAD, /* send headers before dump */
Willy Tarreau96d44912013-11-22 12:25:24 +010041 STAT_HTTP_DUMP, /* dumping stats */
Willy Tarreau347a35d2013-11-22 17:51:09 +010042 STAT_HTTP_POST, /* waiting post data */
43 STAT_HTTP_LAST, /* sending last chunk of response */
Willy Tarreau96d44912013-11-22 12:25:24 +010044};
45
de Lafond Guillaume88c278f2013-04-15 19:27:10 +020046/* HTML form to limit output scope */
47#define STAT_SCOPE_TXT_MAXLEN 20 /* max len for scope substring */
48#define STAT_SCOPE_INPUT_NAME "scope" /* pattern form scope name <input> in html form */
49#define STAT_SCOPE_PATTERN "?" STAT_SCOPE_INPUT_NAME "="
50
William Lallemand9ed62032016-11-21 17:49:11 +010051/* Actions available for the stats admin forms */
52enum {
53 ST_ADM_ACTION_NONE = 0,
Thierry Fournier31e64ca2016-03-23 16:25:49 +010054
William Lallemand9ed62032016-11-21 17:49:11 +010055 /* enable/disable health checks */
56 ST_ADM_ACTION_DHLTH,
57 ST_ADM_ACTION_EHLTH,
58
59 /* force health check status */
60 ST_ADM_ACTION_HRUNN,
61 ST_ADM_ACTION_HNOLB,
62 ST_ADM_ACTION_HDOWN,
63
64 /* enable/disable agent checks */
65 ST_ADM_ACTION_DAGENT,
66 ST_ADM_ACTION_EAGENT,
67
68 /* force agent check status */
69 ST_ADM_ACTION_ARUNN,
70 ST_ADM_ACTION_ADOWN,
71
72 /* set admin state */
73 ST_ADM_ACTION_READY,
74 ST_ADM_ACTION_DRAIN,
75 ST_ADM_ACTION_MAINT,
76 ST_ADM_ACTION_SHUTDOWN,
77 /* these are the ancient actions, still available for compatibility */
78 ST_ADM_ACTION_DISABLE,
79 ST_ADM_ACTION_ENABLE,
80 ST_ADM_ACTION_STOP,
81 ST_ADM_ACTION_START,
Thierry Fournier31e64ca2016-03-23 16:25:49 +010082};
83
Thierry Fournier31e64ca2016-03-23 16:25:49 +010084
William Lallemand9ed62032016-11-21 17:49:11 +010085/* data transmission states for the stats responses */
86enum {
87 STAT_ST_INIT = 0,
88 STAT_ST_HEAD,
89 STAT_ST_INFO,
90 STAT_ST_LIST,
91 STAT_ST_END,
92 STAT_ST_FIN,
Thierry Fournier31e64ca2016-03-23 16:25:49 +010093};
94
William Lallemand9ed62032016-11-21 17:49:11 +010095/* data transmission states for the stats responses inside a proxy */
96enum {
97 STAT_PX_ST_INIT = 0,
98 STAT_PX_ST_TH,
99 STAT_PX_ST_FE,
100 STAT_PX_ST_LI,
101 STAT_PX_ST_SV,
102 STAT_PX_ST_BE,
103 STAT_PX_ST_END,
104 STAT_PX_ST_FIN,
105};
106
Willy Tarreau8e62c052016-01-04 17:23:25 +0100107/* This level of detail is needed to let the stats consumer know how to
108 * aggregate them (eg: between processes or cluster nodes). Only a few
109 * combinations are actually in use, though the mechanism tends to make
110 * this easy to extend to future uses.
111 *
112 * Each reported stats element is typed based on 4 dimensions :
113 * - the field format : it indicates the validity range of the reported value,
114 * its limits and how to parse it. 6 types are currently supported :
115 * empty, signed 32-bit integer, unsigned 32-bit integer, signed 64-bit
116 * integer, unsigned 64-bit integer, string
117 *
118 * - the field origin : how was the value retrieved and what it depends on.
119 * 5 origins are currently defined : product (eg: haproxy version or
120 * release date), configuration (eg: a configured limit), key (identifier
121 * used to group values at a certain level), metric (a measure of something),
122 * status (something discrete which by definition cannot be averaged nor
123 * aggregated, such as "listening" versus "full").
124 *
125 * - the field nature : what does the data represent, implying how to aggregate
126 * it. At least 9 different natures are expected : counter (an increasing
127 * positive counter that may wrap when its type is overflown such as a byte
128 * counter), gauge (a measure at any instant that may vary, such as a
129 * concurrent connection count), a limit (eg: maximum acceptable concurrent
130 * connections), a minimum (eg: minimum free memory over a period), a
131 * maximum (eg: highest queue length over a period), an event rate (eg:
132 * incoming connections per second), a duration that is often aggregated by
133 * taking the max (eg: service uptime), an age that generally reports the
134 * last time an event appeared and which generally is aggregated by taking
135 * the most recent event hence the smallest one, the time which reports a
136 * discrete instant and cannot obviously be averaged either, a name which
137 * will generally be the name of an entity (such as a server name or cookie
138 * name), an output which is mostly used for various unsafe strings that are
139 * retrieved (eg: last check output, product name, description, etc), and an
140 * average which indicates that the value is relative and meant to be averaged
141 * between all nodes (eg: response time, throttling, etc).
142 *
143 * - the field scope : if the value is shared with other elements, which ones
144 * are expected to report the same value. The first scope with the least
145 * share is the process (most common one) where all data are only relevant
146 * to the process being consulted. The next one is the service, which is
147 * valid for all processes launched together (eg: shared SSL cache usage
148 * among processes). The next one is the system (such as the OS version)
149 * and which will report the same information for all instances running on
150 * the same node. The next one is the cluster, which indicates that the
151 * information are shared with other nodes being part of a same cluster.
152 * Stick-tables may carry such cluster-wide information. Larger scopes may
153 * be added in the future such as datacenter, country, continent, planet,
154 * galaxy, universe, etc.
155 *
156 * All these information will be encoded in the field as a bit field so that
157 * it is easy to pass composite values by simply ORing elements above, and
158 * to ease the definition of a few field types for the most common field
159 * combinations.
160 *
161 * The enums try to be arranged so that most likely characteristics are
162 * assigned the value zero, making it easier to add new fields.
163 *
164 * Field format has precedence over the other parts of the type. Please avoid
165 * declaring extra formats unless absolutely needed. The first one, FF_EMPTY,
166 * must absolutely have value zero so that it is what is returned after a
167 * memset(0). Furthermore, the producer is responsible for ensuring that when
168 * this format is set, all other bits of the type as well as the values in the
169 * union only contain zeroes. This makes it easier for the consumer to use the
170 * values as the expected type.
171 */
172
173enum field_format {
174 FF_EMPTY = 0x00000000,
175 FF_S32 = 0x00000001,
176 FF_U32 = 0x00000002,
177 FF_S64 = 0x00000003,
178 FF_U64 = 0x00000004,
179 FF_STR = 0x00000005,
180 FF_MASK = 0x000000FF,
181};
182
183enum field_origin {
184 FO_METRIC = 0x00000000,
185 FO_STATUS = 0x00000100,
186 FO_KEY = 0x00000200,
187 FO_CONFIG = 0x00000300,
188 FO_PRODUCT = 0x00000400,
189 FO_MASK = 0x0000FF00,
190};
191
192enum field_nature {
193 FN_GAUGE = 0x00000000,
194 FN_LIMIT = 0x00010000,
195 FN_MIN = 0x00020000,
196 FN_MAX = 0x00030000,
197 FN_RATE = 0x00040000,
198 FN_COUNTER = 0x00050000,
199 FN_DURATION = 0x00060000,
200 FN_AGE = 0x00070000,
201 FN_TIME = 0x00080000,
202 FN_NAME = 0x00090000,
203 FN_OUTPUT = 0x000A0000,
204 FN_AVG = 0x000B0000,
205 FN_MASK = 0x00FF0000,
206};
207
208enum field_scope {
209 FS_PROCESS = 0x00000000,
210 FS_SERVICE = 0x01000000,
211 FS_SYSTEM = 0x02000000,
212 FS_CLUSTER = 0x03000000,
213 FS_MASK = 0xFF000000,
214};
215
216struct field {
217 uint32_t type;
218 union {
219 int32_t s32; /* FF_S32 */
220 uint32_t u32; /* FF_U32 */
221 int64_t s64; /* FF_S64 */
222 uint64_t u64; /* FF_U64 */
223 const char *str; /* FF_STR */
224 } u;
225};
226
William Lallemand9ed62032016-11-21 17:49:11 +0100227/* Stats fields for CSV output. For any field added here, please add the text
228 * representation in the stat_field_names array below. Please only append at the end,
229 * before the ST_F_TOTAL_FIELDS entry, and never insert anything in the middle
230 * nor at the beginning.
Thierry Fournier31e64ca2016-03-23 16:25:49 +0100231 */
William Lallemand9ed62032016-11-21 17:49:11 +0100232enum stat_field {
233 ST_F_PXNAME,
234 ST_F_SVNAME,
235 ST_F_QCUR,
236 ST_F_QMAX,
237 ST_F_SCUR,
238 ST_F_SMAX,
239 ST_F_SLIM,
240 ST_F_STOT,
241 ST_F_BIN ,
242 ST_F_BOUT,
243 ST_F_DREQ,
244 ST_F_DRESP,
245 ST_F_EREQ,
246 ST_F_ECON,
247 ST_F_ERESP,
248 ST_F_WRETR,
249 ST_F_WREDIS,
250 ST_F_STATUS,
251 ST_F_WEIGHT,
252 ST_F_ACT,
253 ST_F_BCK,
254 ST_F_CHKFAIL,
255 ST_F_CHKDOWN,
256 ST_F_LASTCHG,
257 ST_F_DOWNTIME,
258 ST_F_QLIMIT,
259 ST_F_PID,
260 ST_F_IID,
261 ST_F_SID,
262 ST_F_THROTTLE,
263 ST_F_LBTOT,
264 ST_F_TRACKED,
265 ST_F_TYPE,
266 ST_F_RATE,
267 ST_F_RATE_LIM,
268 ST_F_RATE_MAX,
269 ST_F_CHECK_STATUS,
270 ST_F_CHECK_CODE,
271 ST_F_CHECK_DURATION,
272 ST_F_HRSP_1XX,
273 ST_F_HRSP_2XX,
274 ST_F_HRSP_3XX,
275 ST_F_HRSP_4XX,
276 ST_F_HRSP_5XX,
277 ST_F_HRSP_OTHER,
278 ST_F_HANAFAIL,
279 ST_F_REQ_RATE,
280 ST_F_REQ_RATE_MAX,
281 ST_F_REQ_TOT,
282 ST_F_CLI_ABRT,
283 ST_F_SRV_ABRT,
284 ST_F_COMP_IN,
285 ST_F_COMP_OUT,
286 ST_F_COMP_BYP,
287 ST_F_COMP_RSP,
288 ST_F_LASTSESS,
289 ST_F_LAST_CHK,
290 ST_F_LAST_AGT,
291 ST_F_QTIME,
292 ST_F_CTIME,
293 ST_F_RTIME,
294 ST_F_TTIME,
295 ST_F_AGENT_STATUS,
296 ST_F_AGENT_CODE,
297 ST_F_AGENT_DURATION,
298 ST_F_CHECK_DESC,
299 ST_F_AGENT_DESC,
300 ST_F_CHECK_RISE,
301 ST_F_CHECK_FALL,
302 ST_F_CHECK_HEALTH,
303 ST_F_AGENT_RISE,
304 ST_F_AGENT_FALL,
305 ST_F_AGENT_HEALTH,
306 ST_F_ADDR,
307 ST_F_COOKIE,
308 ST_F_MODE,
309 ST_F_ALGO,
310 ST_F_CONN_RATE,
311 ST_F_CONN_RATE_MAX,
312 ST_F_CONN_TOT,
313 ST_F_INTERCEPTED,
314 ST_F_DCON,
315 ST_F_DSES,
William Lallemand1e08cd82016-10-13 17:57:55 +0200316
William Lallemand9ed62032016-11-21 17:49:11 +0100317 /* must always be the last one */
318 ST_F_TOTAL_FIELDS
William Lallemand1e08cd82016-10-13 17:57:55 +0200319};
320
William Lallemand74c24fb2016-11-21 17:18:36 +0100321
William Lallemand9ed62032016-11-21 17:49:11 +0100322#endif /* _TYPES_STATS_H */