summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faulet <cfaulet@haproxy.com>2021-01-20 15:19:12 +0100
committerChristopher Faulet <cfaulet@haproxy.com>2021-01-21 18:59:30 +0100
commit0312c0d1922103c89905025236c70a4f147f3b01 (patch)
treebf453ab94d7da7a1f59504657827917bcbf4b296
parentb713c4f2951b52681e89208884b723d0434cd81d (diff)
downloadhaproxy-0312c0d1922103c89905025236c70a4f147f3b01.tar.gz
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).
-rw-r--r--contrib/prometheus-exporter/service-prometheus.c13
1 files changed, 13 insertions, 0 deletions
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] = {