MINOR: contrib/prometheus-exporter: filter exported metrics by scope
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 Nov 2019 13:47:08 +0000 (14:47 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Nov 2019 13:11:47 +0000 (14:11 +0100)
commit78407ce156b9dd317ae9f4becccd4afa3d5f8c56
treeb307a28a9a8e4a0407fef4a7b80f1138f0484e34
parent36b536d6c8f94e66109f11973e0c975420b98369
MINOR: contrib/prometheus-exporter: filter exported metrics by scope

Now, the prometheus exporter parses the HTTP query-string to filter or to adapt
the exported metrics. In this first version, it is only possible select the
scopes of metrics to export. To do so, one or more parameters with "scope" as
name must be passed in the query-string, with one of those values: global,
frontend, backend, server or '*' (means all). A scope parameter with no value
means to filter out all scopes (nothing is returned). The scope parameters are
parsed in their appearance order in the query-string. So an empty scope will
reset all scopes already parsed. But it can be overridden by following scope
parameters in the query-string. By default everything is exported.

The filtering can also be done on prometheus scraping configuration, but general
aim is to optimise the source of data to improve load and scraping time. This is
particularly true for huge configuration with thousands of backends and servers.
Also note that this configuration was possible on the previous official haproxy
exporter but with even more parameters to select the needed metrics. Here we
thought it was sufficient to simply avoid a given type of metric. However, more
filters are still possible.

Thanks to William Dauchy. This patch is based on his work.
contrib/prometheus-exporter/README
contrib/prometheus-exporter/service-prometheus.c