diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index c2feccc76a..beca87959d 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -38,6 +38,7 @@ #include #include #include +#include /* Prometheus exporter applet states (appctx->st0) */ enum { @@ -82,12 +83,17 @@ enum { */ #define PROMEX_MAX_METRIC_LENGTH 512 +/* Some labels for build_info */ +#define PROMEX_VERSION_LABEL "version=\"" HAPROXY_VERSION "\"" +#define PROMEX_BUILDINFO_LABEL PROMEX_VERSION_LABEL + /* Matrix used to dump global metrics. Each metric points to the next one to be * processed or 0 to stop the dump. */ const int promex_global_metrics[INF_TOTAL_FIELDS] = { - [INF_NAME] = INF_NBTHREAD, + [INF_NAME] = INF_BUILD_INFO, [INF_VERSION] = 0, [INF_RELEASE_DATE] = 0, + [INF_BUILD_INFO] = INF_NBTHREAD, [INF_NBTHREAD] = INF_NBPROC, [INF_NBPROC] = INF_PROCESS_NUM, [INF_PROCESS_NUM] = INF_UPTIME_SEC, @@ -469,6 +475,7 @@ const struct ist promex_inf_metric_names[INF_TOTAL_FIELDS] = { [INF_NAME] = IST("name"), [INF_VERSION] = IST("version"), [INF_RELEASE_DATE] = IST("release_date"), + [INF_BUILD_INFO] = IST("build_info"), [INF_NBTHREAD] = IST("nbthread"), [INF_NBPROC] = IST("nbproc"), [INF_PROCESS_NUM] = IST("relative_process_id"), @@ -641,6 +648,7 @@ const struct ist promex_inf_metric_desc[INF_TOTAL_FIELDS] = { [INF_NAME] = IST("Product name."), [INF_VERSION] = IST("HAProxy version."), [INF_RELEASE_DATE] = IST("HAProxy release date."), + [INF_BUILD_INFO] = IST("HAProxy build info."), [INF_NBTHREAD] = IST("Configured number of threads."), [INF_NBPROC] = IST("Configured number of processes."), [INF_PROCESS_NUM] = IST("Relative process id, starting at 1."), @@ -813,6 +821,7 @@ const struct ist promex_inf_metric_labels[INF_TOTAL_FIELDS] = { [INF_NAME] = IST(""), [INF_VERSION] = IST(""), [INF_RELEASE_DATE] = IST(""), + [INF_BUILD_INFO] = IST(PROMEX_BUILDINFO_LABEL), [INF_NBTHREAD] = IST(""), [INF_NBPROC] = IST(""), [INF_PROCESS_NUM] = IST(""), @@ -978,6 +987,7 @@ const struct ist promex_inf_metric_types[INF_TOTAL_FIELDS] = { [INF_NAME] = IST("untyped"), [INF_VERSION] = IST("untyped"), [INF_RELEASE_DATE] = IST("untyped"), + [INF_BUILD_INFO] = IST("gauge"), [INF_NBTHREAD] = IST("gauge"), [INF_NBPROC] = IST("gauge"), [INF_PROCESS_NUM] = IST("gauge"), @@ -1327,6 +1337,9 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx) #endif while (appctx->st2 && appctx->st2 < INF_TOTAL_FIELDS) { switch (appctx->st2) { + case INF_BUILD_INFO: + metric = mkf_u32(FN_GAUGE, 1); + break; case INF_NBTHREAD: metric = mkf_u32(FO_CONFIG|FS_SERVICE, global.nbthread); break; diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 70d8b489ae..f37c5419cd 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -323,6 +323,7 @@ enum info_field { INF_BYTES_OUT_RATE, INF_DEBUG_COMMANDS_ISSUED, INF_CUM_LOG_MSGS, + INF_BUILD_INFO, /* must always be the last one */ INF_TOTAL_FIELDS