Comparison

mod_prometheus/mod_prometheus.lua @ 3127:36770ae1148f

mod_prometheus: Don’t shadow variables. [luacheck]
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 21 Jun 2018 22:14:12 +0200
parent 3126:888375de933c
child 3128:a34e7bd87b39
comparison
equal deleted inserted replaced
3126:888375de933c 3127:36770ae1148f
100 100
101 local function get_metrics(event) 101 local function get_metrics(event)
102 local response = event.response; 102 local response = event.response;
103 response.headers.content_type = "text/plain; version=0.4.4"; 103 response.headers.content_type = "text/plain; version=0.4.4";
104 104
105 local response = {}; 105 local answer = {};
106 local timestamp = tostring(get_timestamp()); 106 local timestamp = tostring(get_timestamp());
107 for section, data in pairs(data.data) do 107 for section, content in pairs(data.data) do
108 for key, value in pairs(data) do 108 for key, value in pairs(content) do
109 local name = "prosody_"..section.."_"..key; 109 local name = "prosody_"..section.."_"..key;
110 t_insert(response, repr_help(name, "TODO: add a description here.")); 110 t_insert(answer, repr_help(name, "TODO: add a description here."));
111 t_insert(response, repr_type(name, "gauge")); 111 t_insert(answer, repr_type(name, "gauge"));
112 t_insert(response, repr_sample(name, {}, value, timestamp)); 112 t_insert(answer, repr_sample(name, {}, value, timestamp));
113 end 113 end
114 end 114 end
115 return table.concat(response, ""); 115 return table.concat(answer, "");
116 end 116 end
117 117
118 function module.add_host(module) 118 function module.add_host(module)
119 module:provides("http", { 119 module:provides("http", {
120 default_path = "metrics"; 120 default_path = "metrics";