Comparison

mod_prometheus/mod_prometheus.lua @ 4544:64fa2dd34d43

mod_prometheus: remove space between label k/v pairs It is illegal in OpenMetrics and not needed in the old prometheus format, so we better don't emit it.
author Jonas Schäfer <jonas@wielicki.name>
date Sun, 18 Apr 2021 13:42:07 +0200
parent 4542:fb4a50bf60f1
child 4555:1e70538e4641
comparison
equal deleted inserted replaced
4543:9377b5593cc7 4544:64fa2dd34d43
1 -- Log statistics to Prometheus 1 -- Log statistics to Prometheus
2 -- 2 --
3 -- Copyright (C) 2014 Daurnimator 3 -- Copyright (C) 2014 Daurnimator
4 -- Copyright (C) 2018 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> 4 -- Copyright (C) 2018 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
5 -- Copyright (C) 2021 Jonas Schäfer <jonas@zombofant.net>
5 -- 6 --
6 -- This module is MIT/X11 licensed. 7 -- This module is MIT/X11 licensed.
7 8
8 module:set_global(); 9 module:set_global();
9 10
51 t_insert(values, repr_label(escape_name(key), escape(value))); 52 t_insert(values, repr_label(escape_name(key), escape(value)));
52 end 53 end
53 if #values == 0 then 54 if #values == 0 then
54 return ""; 55 return "";
55 end 56 end
56 return "{"..t_concat(values, ", ").."}"; 57 return "{"..t_concat(values, ",").."}";
57 end 58 end
58 59
59 local function repr_sample(metric, labels, value, timestamp) 60 local function repr_sample(metric, labels, value, timestamp)
60 return escape_name(metric)..repr_labels(labels).." "..value.." "..timestamp.."\n"; 61 return escape_name(metric)..repr_labels(labels).." "..value.." "..timestamp.."\n";
61 end 62 end