From 0312c0d1922103c89905025236c70a4f147f3b01 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 20 Jan 2021 15:19:12 +0100 Subject: [PATCH] MINOR: contrib/prometheus-exporter: Add promex_metric struct defining a metric This structure will be used to define a Prometheus metric, i.e its name, its type (gauge or counter) and its flags. The flags will be used to know for which entities the metric is defined (global, frontend, backend and/or server). --- contrib/prometheus-exporter/service-prometheus.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index bad4be8ea..2dcbb9d7e 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -74,6 +74,12 @@ enum { #define PROMEX_FL_SCOPE_ALL (PROMEX_FL_SCOPE_GLOBAL|PROMEX_FL_SCOPE_FRONT|PROMEX_FL_SCOPE_BACK|PROMEX_FL_SCOPE_SERVER) +/* Promtheus metric type (gauge or counter) */ +enum promex_mt_type { + PROMEX_MT_GAUGE = 1, + PROMEX_MT_COUNTER = 2, +}; + /* The max length for metrics name. It is a hard limit but it should be * enough. */ @@ -89,6 +95,13 @@ enum { #define PROMEX_VERSION_LABEL "version=\"" HAPROXY_VERSION "\"" #define PROMEX_BUILDINFO_LABEL PROMEX_VERSION_LABEL +/* Describe a prometheus metric */ +struct promex_metric { + const struct ist n; /* The metric name */ + enum promex_mt_type type; /* The metric type (gauge or counter) */ + unsigned int flags; /* PROMEX_FL_* flags */ +}; + /* 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] = {