MINOR: promex: Add support for specialized front/back/li/srv metric names
Depending on the scope, metrics can have different names. For instance, the number of active/backend servers are reported with "haproxy_backend_active_servers"/"haproxy_backend_backup_servers" metric names in the backend scope while it should be "haproxy_server_active"/"haproxy_server_backup" in the server scope. To be able to support different names depending on the scope for the same metric, arrays of ISTs were added, one by scope (front, back, listen, server). These arrays only contain names overriding the default ones. Note: the exemple above is not supported for now and is the reason for this commit.
This commit is contained in:
parent
f792a25904
commit
3b8b9b8179
|
@ -306,6 +306,22 @@ const struct promex_metric promex_st_metrics[ST_F_TOTAL_FIELDS] = {
|
||||||
[ST_F_AGG_CHECK_STATUS] = { .n = IST("agg_check_status"), .type = PROMEX_MT_GAUGE, .flags = ( PROMEX_FL_BACK_METRIC ) },
|
[ST_F_AGG_CHECK_STATUS] = { .n = IST("agg_check_status"), .type = PROMEX_MT_GAUGE, .flags = ( PROMEX_FL_BACK_METRIC ) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Specialized frontend metric names, to override default ones */
|
||||||
|
const struct ist promex_st_front_metrics_names[ST_F_TOTAL_FIELDS] = {
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Specialized bakcend metric names, to override default ones */
|
||||||
|
const struct ist promex_st_back_metrics_names[ST_F_TOTAL_FIELDS] = {
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Specialized listener metric names, to override default ones */
|
||||||
|
const struct ist promex_st_li_metrics_names[ST_F_TOTAL_FIELDS] = {
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Specialized server metric names, to override default ones */
|
||||||
|
const struct ist promex_st_srv_metrics_names[ST_F_TOTAL_FIELDS] = {
|
||||||
|
};
|
||||||
|
|
||||||
/* Description of overridden stats fields */
|
/* Description of overridden stats fields */
|
||||||
const struct ist promex_st_metric_desc[ST_F_TOTAL_FIELDS] = {
|
const struct ist promex_st_metric_desc[ST_F_TOTAL_FIELDS] = {
|
||||||
[ST_F_STATUS] = IST("Current status of the service, per state label value."),
|
[ST_F_STATUS] = IST("Current status of the service, per state label value."),
|
||||||
|
@ -490,8 +506,8 @@ static int promex_dump_metric_header(struct appctx *appctx, struct htx *htx,
|
||||||
* success. Otherwise if <out> length exceeds <max>, it returns 0.
|
* success. Otherwise if <out> length exceeds <max>, it returns 0.
|
||||||
*/
|
*/
|
||||||
static int promex_dump_metric(struct appctx *appctx, struct htx *htx, struct ist prefix,
|
static int promex_dump_metric(struct appctx *appctx, struct htx *htx, struct ist prefix,
|
||||||
const struct promex_metric *metric, struct field *val,
|
const struct ist n, const struct promex_metric *metric,
|
||||||
struct promex_label *labels, struct ist *out, size_t max)
|
struct field *val, struct promex_label *labels, struct ist *out, size_t max)
|
||||||
{
|
{
|
||||||
struct ist name = { .ptr = (char[PROMEX_MAX_NAME_LEN]){ 0 }, .len = 0 };
|
struct ist name = { .ptr = (char[PROMEX_MAX_NAME_LEN]){ 0 }, .len = 0 };
|
||||||
struct promex_ctx *ctx = appctx->svcctx;
|
struct promex_ctx *ctx = appctx->svcctx;
|
||||||
|
@ -502,7 +518,7 @@ static int promex_dump_metric(struct appctx *appctx, struct htx *htx, struct ist
|
||||||
|
|
||||||
/* Fill the metric name */
|
/* Fill the metric name */
|
||||||
istcat(&name, prefix, PROMEX_MAX_NAME_LEN);
|
istcat(&name, prefix, PROMEX_MAX_NAME_LEN);
|
||||||
istcat(&name, metric->n, PROMEX_MAX_NAME_LEN);
|
istcat(&name, (isttest(n) ? n : metric->n), PROMEX_MAX_NAME_LEN);
|
||||||
|
|
||||||
|
|
||||||
if ((ctx->flags & PROMEX_FL_METRIC_HDR) &&
|
if ((ctx->flags & PROMEX_FL_METRIC_HDR) &&
|
||||||
|
@ -585,7 +601,7 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = info[ctx->field_num];
|
val = info[ctx->field_num];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_global_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix, IST_NULL, &promex_global_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
|
|
||||||
|
@ -645,7 +661,9 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
labels[1].name = ist("state");
|
labels[1].name = ist("state");
|
||||||
labels[1].value = promex_front_st[ctx->obj_state];
|
labels[1].value = promex_front_st[ctx->obj_state];
|
||||||
val = mkf_u32(FO_STATUS, state == ctx->obj_state);
|
val = mkf_u32(FO_STATUS, state == ctx->obj_state);
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_front_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -683,7 +701,9 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = stats[ctx->field_num];
|
val = stats[ctx->field_num];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_front_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
next_px:
|
next_px:
|
||||||
|
@ -757,7 +777,9 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = mkf_u32(FO_STATUS, status == ctx->obj_state);
|
val = mkf_u32(FO_STATUS, status == ctx->obj_state);
|
||||||
labels[2].name = ist("state");
|
labels[2].name = ist("state");
|
||||||
labels[2].value = ist(li_status_st[ctx->obj_state]);
|
labels[2].value = ist(li_status_st[ctx->obj_state]);
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_li_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -768,6 +790,7 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!promex_dump_metric(appctx, htx, prefix,
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_li_metrics_names[ctx->field_num],
|
||||||
&promex_st_metrics[ctx->field_num],
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
|
@ -852,7 +875,9 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = mkf_u32(FN_GAUGE, srv_state_count[ctx->obj_state]);
|
val = mkf_u32(FN_GAUGE, srv_state_count[ctx->obj_state]);
|
||||||
labels[1].name = ist("state");
|
labels[1].name = ist("state");
|
||||||
labels[1].value = promex_srv_st[ctx->obj_state];
|
labels[1].value = promex_srv_st[ctx->obj_state];
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_back_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -876,7 +901,9 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
check_state = get_check_status_info(ctx->obj_state);
|
check_state = get_check_status_info(ctx->obj_state);
|
||||||
labels[1].name = ist("state");
|
labels[1].name = ist("state");
|
||||||
labels[1].value = ist(check_state);
|
labels[1].value = ist(check_state);
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_back_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -888,7 +915,9 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
labels[1].name = ist("state");
|
labels[1].name = ist("state");
|
||||||
labels[1].value = promex_back_st[ctx->obj_state];
|
labels[1].value = promex_back_st[ctx->obj_state];
|
||||||
val = mkf_u32(FO_STATUS, bkd_state == ctx->obj_state);
|
val = mkf_u32(FO_STATUS, bkd_state == ctx->obj_state);
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_back_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -956,7 +985,9 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = stats[ctx->field_num];
|
val = stats[ctx->field_num];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_back_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
next_px:
|
next_px:
|
||||||
|
@ -1031,7 +1062,9 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = mkf_u32(FO_STATUS, state == ctx->obj_state);
|
val = mkf_u32(FO_STATUS, state == ctx->obj_state);
|
||||||
labels[2].name = ist("state");
|
labels[2].name = ist("state");
|
||||||
labels[2].value = promex_srv_st[ctx->obj_state];
|
labels[2].value = promex_srv_st[ctx->obj_state];
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_srv_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -1080,7 +1113,9 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
check_state = get_check_status_info(ctx->obj_state);
|
check_state = get_check_status_info(ctx->obj_state);
|
||||||
labels[2].name = ist("state");
|
labels[2].name = ist("state");
|
||||||
labels[2].value = ist(check_state);
|
labels[2].value = ist(check_state);
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_srv_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1156,9 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||||
val = stats[ctx->field_num];
|
val = stats[ctx->field_num];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!promex_dump_metric(appctx, htx, prefix, &promex_st_metrics[ctx->field_num],
|
if (!promex_dump_metric(appctx, htx, prefix,
|
||||||
|
promex_st_srv_metrics_names[ctx->field_num],
|
||||||
|
&promex_st_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
next_sv:
|
next_sv:
|
||||||
|
@ -1189,7 +1226,7 @@ static int promex_dump_sticktable_metrics(struct appctx *appctx, struct htx *htx
|
||||||
goto next_px;
|
goto next_px;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!promex_dump_metric(appctx, htx, prefix,
|
if (!promex_dump_metric(appctx, htx, prefix, IST_NULL,
|
||||||
&promex_sticktable_metrics[ctx->field_num],
|
&promex_sticktable_metrics[ctx->field_num],
|
||||||
&val, labels, &out, max))
|
&val, labels, &out, max))
|
||||||
goto full;
|
goto full;
|
||||||
|
|
Loading…
Reference in New Issue