next master upon reload, so that it remains stable for the whole life of
the master, and it is also exposed to the worker. Its format is the same as
the one of the proxies' and servers' "guid": at most 127 characters among
- letters, digits, '.', ':', '-' and '_'.
+ letters, digits, '.', ':', '-' and '_'. See also the "master_id" sample
+ fetch function.
* HAPROXY_WORKER_ID: unique identifier of the worker process. It is randomly
generated at boot on the worker process, and may be overwritten by the
set before the worker reads the rest of its configuration, so it may be
referenced from there, and being part of the process' environment it is
also visible to Lua (os.getenv()) and inherited by the processes launched
- from the worker, such as external health checks.
+ from the worker, such as external health checks. See also the "worker_id"
+ sample fetch function.
* HAPROXY_STARTUP_VERSION: contains the version used to start, in master-
worker mode this is the version which was used to start the master, even
worker-id "pop7-node1-inst3-${HAPROXY_WORKER_ID}"
The identifier is exported as the HAPROXY_WORKER_ID environment variable (see
- section 2.3). See also HAPROXY_MASTER_ID in section 2.3.
+ section 2.3) and is returned by the "worker_id" sample fetch function. See
+ also HAPROXY_MASTER_ID in section 2.3, and the "worker_id" sample fetch
+ function.
wurfl-cache-size <size>
Sets the WURFL Useragent cache size. For faster lookups, already processed user
last_rule_line integer
lat_ns_avg integer
lat_ns_tot integer
+master_id string
meth(<method>) method
nbsrv([<backend>]) integer
pid integer
var(<var-name>[,<default>]) undefined
wait_end boolean
waiting_entity string
+worker_id string
-------------------------------------------------+-------------
Detailed list:
processing many HTTP chunks, and for this reason it is often preferred to log
lat_ns_avg instead, which is a more relevant performance indicator.
+master_id : string
+ Returns the unique identifier of the master process, as found in the
+ HAPROXY_MASTER_ID environment variable (see section 2.3). This identifier is
+ preserved across reloads, so it designates this installation for as long as
+ the master lives. This sample fetch function returns nothing when there is no
+ master, i.e. when not running in master-worker mode. See also "worker_id".
+ Note that this string has its own storage, and that changing the contents of
+ HAPROXY_MASTER_ID via "setenv" will not affect it.
+
meth(<method>) : method
Returns a method.
# Log the waiting entity, if any, and only if an error is reported
log-format "$HAPROXY_HTTP_LOG_FMT %{Q}[waiting_entity,when(error)]
+worker_id : string
+ Returns the unique identifier of the current worker process, either the one
+ set with the "worker-id" keyword in the global section, or the random one
+ which was generated at boot. In the latter case it changes on every reload,
+ so that a newly started worker may be told from the previous ones. Combined
+ with "master_id", which does not change across reloads, this permits an
+ external monitoring system to correlate the traffic it sees with the process
+ it collects its metrics from, for example:
+
+ log-format "$HAPROXY_HTTP_LOG_FMT mid=%[master_id] wid=%[worker_id]"
+
+ Note that this string has its own storage, and that changing the contents of
+ HAPROXY_WORKER_ID via "setenv" will not affect it. See also the "master_id"
+ sample fetch function, and the "worker-id" global keyword.
+
7.3.3. Fetching samples at Layer 4
----------------------------------
return 1;
}
+/* returns the unique identifier of the master process. Fails when there is no
+ * master, i.e. when not running in master-worker mode.
+ */
+static int
+smp_fetch_master_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
+{
+ if (!global.master_id)
+ return 0;
+
+ smp->data.type = SMP_T_STR;
+ smp->flags = SMP_F_CONST;
+ smp->data.u.str.area = global.master_id;
+ smp->data.u.str.data = strlen(global.master_id);
+ return 1;
+}
+
+/* returns the unique identifier of the current worker process */
+static int
+smp_fetch_worker_id(const struct arg *args, struct sample *smp, const char *kw, void *private)
+{
+ if (!global.worker_id)
+ return 0;
+
+ smp->data.type = SMP_T_STR;
+ smp->flags = SMP_F_CONST;
+ smp->data.u.str.area = global.worker_id;
+ smp->data.u.str.data = strlen(global.worker_id);
+ return 1;
+}
+
/* returns the number of processes */
static int
smp_fetch_nbproc(const struct arg *args, struct sample *smp, const char *kw, void *private)
{ "date", smp_fetch_date, ARG2(0,SINT,STR), smp_check_date_unit, SMP_T_SINT, SMP_USE_CONST },
{ "date_us", smp_fetch_date_us, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
{ "hostname", smp_fetch_hostname, 0, NULL, SMP_T_STR, SMP_USE_CONST },
+ { "master_id", smp_fetch_master_id, 0, NULL, SMP_T_STR, SMP_USE_CONST },
{ "nbproc", smp_fetch_nbproc,0, NULL, SMP_T_SINT, SMP_USE_CONST },
{ "pid", smp_fetch_pid, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
{ "proc", smp_fetch_proc, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
{ "stopping", smp_fetch_stopping, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
{ "uptime", smp_fetch_uptime, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
{ "uuid", smp_fetch_uuid, ARG1(0, SINT), smp_check_uuid, SMP_T_STR, SMP_USE_CONST },
+ { "worker_id", smp_fetch_worker_id, 0, NULL, SMP_T_STR, SMP_USE_CONST },
{ "cpu_calls", smp_fetch_cpu_calls, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
{ "cpu_ns_avg", smp_fetch_cpu_ns_avg, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },