MINOR: stats: duplicate 3 fields in bytes in info

in order to prepare a possible merge of fields between haproxy stats and
prometheus, duplicate 3 fields:
  INF_MEMMAX
  INF_POOL_ALLOC
  INF_POOL_USED
Those were specifically named in MB unit which is not what prometheus
recommends. We therefore used them but changed the unit while doing the
calculation. It created a specific case for that, up to the description.
This patch:
- removes some possible confusion, i.e. using MB field for bytes
- will permit an easier merge of fields such as description

First consequence for now, is that we can remove the calculation on
prometheus side and move it on `fill_info`.

Signed-off-by: William Dauchy <wdauchy@gmail.com>
This commit is contained in:
William Dauchy 2021-01-15 22:41:37 +01:00 committed by Christopher Faulet
parent ef4e45ca55
commit a8766cfad1
3 changed files with 25 additions and 25 deletions

View File

@ -99,10 +99,10 @@ const int promex_global_metrics[INF_TOTAL_FIELDS] = {
[INF_PROCESS_NUM] = INF_UPTIME_SEC,
[INF_PID] = 0,
[INF_UPTIME] = 0,
[INF_UPTIME_SEC] = INF_MEMMAX_MB,
[INF_MEMMAX_MB] = INF_POOL_ALLOC_MB,
[INF_POOL_ALLOC_MB] = INF_POOL_USED_MB,
[INF_POOL_USED_MB] = INF_POOL_FAILED,
[INF_UPTIME_SEC] = INF_MEMMAX_BYTES,
[INF_MEMMAX_BYTES] = INF_POOL_ALLOC_BYTES,
[INF_POOL_ALLOC_BYTES] = INF_POOL_USED_BYTES,
[INF_POOL_USED_BYTES] = INF_POOL_FAILED,
[INF_POOL_FAILED] = INF_ULIMIT_N,
[INF_ULIMIT_N] = INF_MAXSOCK,
[INF_MAXSOCK] = INF_MAXCONN,
@ -482,9 +482,9 @@ const struct ist promex_inf_metric_names[INF_TOTAL_FIELDS] = {
[INF_PID] = IST("pid"),
[INF_UPTIME] = IST("uptime"),
[INF_UPTIME_SEC] = IST("start_time_seconds"),
[INF_MEMMAX_MB] = IST("max_memory_bytes"),
[INF_POOL_ALLOC_MB] = IST("pool_allocated_bytes"),
[INF_POOL_USED_MB] = IST("pool_used_bytes"),
[INF_MEMMAX_BYTES] = IST("max_memory_bytes"),
[INF_POOL_ALLOC_BYTES] = IST("pool_allocated_bytes"),
[INF_POOL_USED_BYTES] = IST("pool_used_bytes"),
[INF_POOL_FAILED] = IST("pool_failures_total"),
[INF_ULIMIT_N] = IST("max_fds"),
[INF_MAXSOCK] = IST("max_sockets"),
@ -655,9 +655,9 @@ const struct ist promex_inf_metric_desc[INF_TOTAL_FIELDS] = {
[INF_PID] = IST("HAProxy PID."),
[INF_UPTIME] = IST("Uptime in a human readable format."),
[INF_UPTIME_SEC] = IST("Start time in seconds."),
[INF_MEMMAX_MB] = IST("Per-process memory limit (in bytes); 0=unset."),
[INF_POOL_ALLOC_MB] = IST("Total amount of memory allocated in pools (in bytes)."),
[INF_POOL_USED_MB] = IST("Total amount of memory used in pools (in bytes)."),
[INF_MEMMAX_BYTES] = IST("Per-process memory limit (in bytes); 0=unset."),
[INF_POOL_ALLOC_BYTES] = IST("Total amount of memory allocated in pools (in bytes)."),
[INF_POOL_USED_BYTES] = IST("Total amount of memory used in pools (in bytes)."),
[INF_POOL_FAILED] = IST("Total number of failed pool allocations."),
[INF_ULIMIT_N] = IST("Maximum number of open file descriptors; 0=unset."),
[INF_MAXSOCK] = IST("Maximum number of open sockets."),
@ -828,9 +828,9 @@ const struct ist promex_inf_metric_labels[INF_TOTAL_FIELDS] = {
[INF_PID] = IST(""),
[INF_UPTIME] = IST(""),
[INF_UPTIME_SEC] = IST(""),
[INF_MEMMAX_MB] = IST(""),
[INF_POOL_ALLOC_MB] = IST(""),
[INF_POOL_USED_MB] = IST(""),
[INF_MEMMAX_BYTES] = IST(""),
[INF_POOL_ALLOC_BYTES] = IST(""),
[INF_POOL_USED_BYTES] = IST(""),
[INF_POOL_FAILED] = IST(""),
[INF_ULIMIT_N] = IST(""),
[INF_MAXSOCK] = IST(""),
@ -994,9 +994,9 @@ const struct ist promex_inf_metric_types[INF_TOTAL_FIELDS] = {
[INF_PID] = IST("untyped"),
[INF_UPTIME] = IST("untyped"),
[INF_UPTIME_SEC] = IST("gauge"),
[INF_MEMMAX_MB] = IST("gauge"),
[INF_POOL_ALLOC_MB] = IST("gauge"),
[INF_POOL_USED_MB] = IST("gauge"),
[INF_MEMMAX_BYTES] = IST("gauge"),
[INF_POOL_ALLOC_BYTES] = IST("gauge"),
[INF_POOL_USED_BYTES] = IST("gauge"),
[INF_POOL_FAILED] = IST("counter"),
[INF_ULIMIT_N] = IST("gauge"),
[INF_MAXSOCK] = IST("gauge"),
@ -1336,15 +1336,6 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
case INF_UPTIME_SEC:
metric = mkf_u32(FN_DURATION, start_date.tv_sec);
break;
case INF_MEMMAX_MB:
metric = mkf_u64(FO_CONFIG|FN_LIMIT, global.rlimit_memmax * 1048576L);
break;
case INF_POOL_ALLOC_MB:
metric = mkf_u64(0, pool_total_allocated());
break;
case INF_POOL_USED_MB:
metric = mkf_u64(0, pool_total_used());
break;
default:
metric = info[appctx->st2];

View File

@ -324,6 +324,9 @@ enum info_field {
INF_DEBUG_COMMANDS_ISSUED,
INF_CUM_LOG_MSGS,
INF_BUILD_INFO,
INF_MEMMAX_BYTES,
INF_POOL_ALLOC_BYTES,
INF_POOL_USED_BYTES,
/* must always be the last one */
INF_TOTAL_FIELDS

View File

@ -92,8 +92,11 @@ const struct name_desc info_fields[INF_TOTAL_FIELDS] = {
[INF_UPTIME] = { .name = "Uptime", .desc = "How long ago this worker process was started (days+hours+minutes+seconds)" },
[INF_UPTIME_SEC] = { .name = "Uptime_sec", .desc = "How long ago this worker process was started (seconds)" },
[INF_MEMMAX_MB] = { .name = "Memmax_MB", .desc = "Worker process's hard limit on memory usage in MB (-m on command line)" },
[INF_MEMMAX_BYTES] = { .name = "Memmax_bytes", .desc = "Worker process's hard limit on memory usage in byes (-m on command line)" },
[INF_POOL_ALLOC_MB] = { .name = "PoolAlloc_MB", .desc = "Amount of memory allocated in pools (in MB)" },
[INF_POOL_ALLOC_BYTES] = { .name = "PoolAlloc_bytes", .desc = "Amount of memory allocated in pools (in bytes)" },
[INF_POOL_USED_MB] = { .name = "PoolUsed_MB", .desc = "Amount of pool memory currently used (in MB)" },
[INF_POOL_USED_BYTES] = { .name = "PoolUsed_bytes", .desc = "Amount of pool memory currently used (in bytes)" },
[INF_POOL_FAILED] = { .name = "PoolFailed", .desc = "Number of failed pool allocations since this worker was started" },
[INF_ULIMIT_N] = { .name = "Ulimit-n", .desc = "Hard limit on the number of per-process file descriptors" },
[INF_MAXSOCK] = { .name = "Maxsock", .desc = "Hard limit on the number of per-process sockets" },
@ -3849,8 +3852,11 @@ int stats_fill_info(struct field *info, int len)
info[INF_UPTIME_SEC] = mkf_u32(FN_DURATION, up);
info[INF_MEMMAX_MB] = mkf_u32(FO_CONFIG|FN_LIMIT, global.rlimit_memmax);
info[INF_MEMMAX_BYTES] = mkf_u32(FO_CONFIG|FN_LIMIT, global.rlimit_memmax * 1048576L);
info[INF_POOL_ALLOC_MB] = mkf_u32(0, (unsigned)(pool_total_allocated() / 1048576L));
info[INF_POOL_ALLOC_BYTES] = mkf_u32(0, pool_total_allocated());
info[INF_POOL_USED_MB] = mkf_u32(0, (unsigned)(pool_total_used() / 1048576L));
info[INF_POOL_USED_BYTES] = mkf_u32(0, pool_total_used());
info[INF_POOL_FAILED] = mkf_u32(FN_COUNTER, pool_total_failures());
info[INF_ULIMIT_N] = mkf_u32(FO_CONFIG|FN_LIMIT, global.rlimit_nofile);
info[INF_MAXSOCK] = mkf_u32(FO_CONFIG|FN_LIMIT, global.maxsock);