annotate mod_prometheus/mod_prometheus.lua @ 3131:ddd39ca7b953

mod_prometheus: Change the storage model for one which matches Prometheus better.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 22 Jun 2018 00:31:54 +0200
parents a34e7bd87b39
children 4ef28b6b4e87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 -- Log common stats to statsd
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 --
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 -- Copyright (C) 2014 Daurnimator
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 --
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 -- This module is MIT/X11 licensed.
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 module:set_global();
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 module:depends "http";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9
3128
a34e7bd87b39 mod_prometheus: Optimise global lookups.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3127
diff changeset
10 local tostring = tostring;
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 local t_insert = table.insert;
3128
a34e7bd87b39 mod_prometheus: Optimise global lookups.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3127
diff changeset
12 local t_concat = table.concat;
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 local socket = require "socket";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
3131
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
15 local data = {};
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 local function escape(text)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 return text:gsub("\\", "\\\\"):gsub("\"", "\\\""):gsub("\n", "\\n");
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 local function escape_name(name)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 return name:gsub("[^A-Za-z0-9_]", "_"):gsub("^[^A-Za-z_]", "_%1");
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 local function get_timestamp()
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 -- Using LuaSocket for that because os.time() only has second precision.
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 return math.floor(socket.gettime() * 1000);
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 local function repr_help(metric, docstring)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 docstring = docstring:gsub("\\", "\\\\"):gsub("\n", "\\n");
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 return "# HELP "..escape_name(metric).." "..docstring.."\n";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 -- local allowed_types = { counter = true, gauge = true, histogram = true, summary = true, untyped = true };
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 -- local allowed_types = { "counter", "gauge", "histogram", "summary", "untyped" };
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 local function repr_type(metric, type_)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 -- if not allowed_types:contains(type_) then
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 -- return;
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 -- end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 return "# TYPE "..escape_name(metric).." "..type_.."\n";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 local function repr_label(key, value)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 return key.."=\""..escape(value).."\"";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 local function repr_labels(labels)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 local values = {}
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 for key, value in pairs(labels) do
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 t_insert(values, repr_label(escape_name(key), escape(value)));
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 if #values == 0 then
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 return "";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 end
3128
a34e7bd87b39 mod_prometheus: Optimise global lookups.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3127
diff changeset
56 return "{"..t_concat(values, ", ").."}";
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 local function repr_sample(metric, labels, value, timestamp)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 return escape_name(metric)..repr_labels(labels).." "..value.." "..timestamp.."\n";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 module:hook("stats-updated", function (event)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 local all_stats, this = event.stats_extra;
3131
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
65 local host, sect, name, typ;
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
66 data = {};
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
67 for stat, value in pairs(event.stats) do
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 this = all_stats[stat];
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 -- module:log("debug", "changed_stats[%q] = %s", stat, tostring(value));
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 host, sect, name, typ = stat:match("^/([^/]+)/([^/]+)/(.+):(%a+)$");
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 if host == nil then
3131
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
72 sect, name, typ = stat:match("^([^.]+)%.(.+):(%a+)$");
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 elseif host == "*" then
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 host = nil;
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 if sect:find("^mod_measure_.") then
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 sect = sect:sub(13);
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 elseif sect:find("^mod_statistics_.") then
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 sect = sect:sub(16);
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81
3131
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
82 local key = escape_name("prosody_"..sect.."_"..name);
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
83 local field = {
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
84 value = value,
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
85 labels = {},
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
86 -- TODO: Use the other types where it makes sense.
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
87 typ = (typ == "rate" and "counter" or "gauge"),
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
88 };
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
89 if host then
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
90 field.labels.host = host;
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 end
3131
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
92 if data[key] == nil then
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
93 data[key] = {};
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
94 end
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
95 t_insert(data[key], field);
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 end);
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99 local function get_metrics(event)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 local response = event.response;
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 response.headers.content_type = "text/plain; version=0.4.4";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102
3127
36770ae1148f mod_prometheus: Don’t shadow variables. [luacheck]
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3126
diff changeset
103 local answer = {};
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 local timestamp = tostring(get_timestamp());
3131
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
105 for key, fields in pairs(data) do
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
106 t_insert(answer, repr_help(key, "TODO: add a description here."));
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
107 t_insert(answer, repr_type(key, fields[1].typ));
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
108 for _, field in pairs(fields) do
ddd39ca7b953 mod_prometheus: Change the storage model for one which matches Prometheus better.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3128
diff changeset
109 t_insert(answer, repr_sample(key, field.labels, field.value, timestamp));
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 end
3128
a34e7bd87b39 mod_prometheus: Optimise global lookups.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 3127
diff changeset
112 return t_concat(answer, "");
3125
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 end
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115 function module.add_host(module)
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 module:provides("http", {
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 default_path = "metrics";
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 route = {
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 GET = get_metrics;
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 };
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 });
07a2ba55de4d mod_prometheus: Add a new statistics export module, for Prometheus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 end