Software /
code /
prosody
Changeset
11931:c65d5da8e99a
mod_admin_shell: List collected metrics in module:info
Lets you know what to look for with stats:show()
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Nov 2021 20:03:38 +0100 |
parents | 11930:ec46f110ce1d |
children | 11932:92925f1320e7 |
files | core/moduleapi.lua plugins/mod_admin_shell.lua |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Tue Nov 23 17:59:40 2021 +0100 +++ b/core/moduleapi.lua Wed Nov 24 20:03:38 2021 +0100 @@ -531,6 +531,7 @@ -- an array of labels -- the prosody_ prefix is automatically added by statsmanager for legacy -- metrics. + self:add_item("measure", { name = name, type = stat_type, conf = conf }); return measure(stat_type, "mod_"..self.name.."/"..name, conf, fixed_label_key, fixed_label_value) end @@ -544,6 +545,7 @@ label_keys:append(orig_labels) end local mf = metric(type_, "prosody_mod_"..self.name.."/"..name, unit, description, label_keys, conf) + self:add_item("metric", { name = name, mf = mf }); if is_scoped then -- make sure to scope the returned metric family to the current host return mf:with_partial_label(self.host)
--- a/plugins/mod_admin_shell.lua Tue Nov 23 17:59:40 2021 +0100 +++ b/plugins/mod_admin_shell.lua Wed Nov 24 20:03:38 2021 +0100 @@ -47,6 +47,16 @@ return (s:gsub("^%a", string.upper):gsub("_", " ")); end +local function pre(prefix, str, alt) + if (str or "") == "" then return alt or ""; end + return prefix .. str; +end + +local function suf(str, suffix, alt) + if (str or "") == "" then return alt or ""; end + return str .. suffix; +end + local commands = module:shared("commands") local def_env = module:shared("env"); local default_env_mt = { __index = def_env }; @@ -422,6 +432,8 @@ ["http-provider"] = "HTTP services", ["net-provider"] = "Network service", ["storage-provider"] = "Storage driver", + ["measure"] = "Legacy metrics", + ["metric"] = "Metrics", }; local item_formatters = { ["feature"] = tostring, @@ -431,6 +443,10 @@ ["storage-provider"] = function(item) return item.name; end, ["http-provider"] = function(item, mod) return mod:http_url(item.name); end, ["net-provider"] = function(item) return item.name; end, + ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, + ["metric"] = function(item) + return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); + end, }; for host in hosts do