Skip to content

Commit 451d216

Browse files
committed
MINOR: promex: Expose the global node and description in process metrics
The global node value is now exposed via "haproxy_process_node" metrics. The metric value is always set to 1 and the node name itself is the "node" label. The same is performed for the global description. But only if it is defined. In that case "haproxy_process_description" metric is defined, with 1 as value and the description itself is set in the "desc" label.
1 parent a930e99 commit 451d216

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

addons/promex/README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ listed below. Metrics from extra counters are not listed.
193193
| haproxy_process_current_tasks |
194194
| haproxy_process_current_run_queue |
195195
| haproxy_process_idle_time_percent |
196+
| haproxy_process_node |
197+
| haproxy_process_description |
196198
| haproxy_process_stopping |
197199
| haproxy_process_jobs |
198200
| haproxy_process_unstoppable_jobs |

addons/promex/service-prometheus.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ const struct promex_metric promex_global_metrics[ST_I_INF_MAX] = {
153153
[ST_I_INF_TASKS] = { .n = IST("current_tasks"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
154154
[ST_I_INF_RUN_QUEUE] = { .n = IST("current_run_queue"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
155155
[ST_I_INF_IDLE_PCT] = { .n = IST("idle_time_percent"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
156-
//[ST_I_INF_NODE] ignored
157-
//[ST_I_INF_DESCRIPTION] ignored
156+
[ST_I_INF_NODE] = { .n = IST("node"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
157+
[ST_I_INF_DESCRIPTION] = { .n = IST("description"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
158158
[ST_I_INF_STOPPING] = { .n = IST("stopping"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
159159
[ST_I_INF_JOBS] = { .n = IST("jobs"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
160160
[ST_I_INF_UNSTOPPABLE_JOBS] = { .n = IST("unstoppable_jobs"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
@@ -580,6 +580,20 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
580580
continue;
581581

582582
switch (ctx->field_num) {
583+
case ST_I_INF_NODE:
584+
labels[0].name = ist("node");
585+
labels[0].value = ist(global.node);
586+
val = mkf_u32(FN_GAUGE, 1);
587+
break;
588+
589+
case ST_I_INF_DESCRIPTION:
590+
if (!global.desc)
591+
continue;
592+
labels[0].name = ist("desc");
593+
labels[0].value = ist(global.desc);
594+
val = mkf_u32(FN_GAUGE, 1);
595+
break;
596+
583597
case ST_I_INF_BUILD_INFO:
584598
labels[0].name = ist("version");
585599
labels[0].value = ist(HAPROXY_VERSION);

0 commit comments

Comments
 (0)