mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: contrib/prometheus-exporter: Add a param to ignore servers in maintenance
By passing the parameter "no-maint" in the query-string, it is now possible to ignore servers in maintenance. It means that the metrics for servers in this state will not be exported.
This commit is contained in:
parent
78407ce156
commit
eba2294e5b
@ -73,6 +73,14 @@ exported. Here are examples:
|
|||||||
/metrics?scope=*&scope= # ==> no metrics will be exported
|
/metrics?scope=*&scope= # ==> no metrics will be exported
|
||||||
/metrics?scope=&scope=global # ==> global metrics will be exported
|
/metrics?scope=&scope=global # ==> global metrics will be exported
|
||||||
|
|
||||||
|
* Filtering on servers state
|
||||||
|
|
||||||
|
It is possible to exclude from returned metrics all servers in maintenance mode
|
||||||
|
passing the parameter "no-maint" in the query-string. This parameter may help to
|
||||||
|
solve performance issues of configuration that use the server templates to
|
||||||
|
manage dynamic provisionning. Note there is no consistency check on the servers
|
||||||
|
state. So, if the state of a server changes while the exporter is running, only
|
||||||
|
a part of the metrics for this server will be dumped.
|
||||||
|
|
||||||
Exported metrics
|
Exported metrics
|
||||||
------------------
|
------------------
|
||||||
|
@ -68,6 +68,7 @@ enum {
|
|||||||
#define PROMEX_FL_SCOPE_FRONT 0x00000010
|
#define PROMEX_FL_SCOPE_FRONT 0x00000010
|
||||||
#define PROMEX_FL_SCOPE_BACK 0x00000020
|
#define PROMEX_FL_SCOPE_BACK 0x00000020
|
||||||
#define PROMEX_FL_SCOPE_SERVER 0x00000040
|
#define PROMEX_FL_SCOPE_SERVER 0x00000040
|
||||||
|
#define PROMEX_FL_NO_MAINT_SRV 0x00000080
|
||||||
|
|
||||||
#define PROMEX_FL_SCOPE_ALL (PROMEX_FL_SCOPE_GLOBAL|PROMEX_FL_SCOPE_FRONT|PROMEX_FL_SCOPE_BACK|PROMEX_FL_SCOPE_SERVER)
|
#define PROMEX_FL_SCOPE_ALL (PROMEX_FL_SCOPE_GLOBAL|PROMEX_FL_SCOPE_FRONT|PROMEX_FL_SCOPE_BACK|PROMEX_FL_SCOPE_SERVER)
|
||||||
|
|
||||||
@ -1905,6 +1906,9 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
|||||||
while (appctx->ctx.stats.sv) {
|
while (appctx->ctx.stats.sv) {
|
||||||
sv = appctx->ctx.stats.sv;
|
sv = appctx->ctx.stats.sv;
|
||||||
|
|
||||||
|
if ((appctx->ctx.stats.flags & PROMEX_FL_NO_MAINT_SRV) && (sv->cur_admin & SRV_ADMF_MAINT))
|
||||||
|
goto next_sv;
|
||||||
|
|
||||||
switch (appctx->st2) {
|
switch (appctx->st2) {
|
||||||
case ST_F_STATUS:
|
case ST_F_STATUS:
|
||||||
metric = mkf_u32(FO_STATUS, promex_srv_status(sv));
|
metric = mkf_u32(FO_STATUS, promex_srv_status(sv));
|
||||||
@ -2075,6 +2079,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
|||||||
if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
|
if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
|
|
||||||
|
next_sv:
|
||||||
appctx->ctx.stats.sv = sv->next;
|
appctx->ctx.stats.sv = sv->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2271,6 +2276,10 @@ static int promex_parse_uri(struct appctx *appctx, struct stream_interface *si)
|
|||||||
|
|
||||||
p += len;
|
p += len;
|
||||||
}
|
}
|
||||||
|
else if (*p == 'n' && (end-p) >= 8 && !memcmp(p, "no-maint", 8)) {
|
||||||
|
appctx->ctx.stats.flags |= PROMEX_FL_NO_MAINT_SRV;
|
||||||
|
p += 8;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
/* ignore all other params for now */
|
/* ignore all other params for now */
|
||||||
while (p < end && *p != '&')
|
while (p < end && *p != '&')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user