diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /examples/rgw/lua/prometheus_adapter.lua | |
parent | Initial commit. (diff) | |
download | ceph-upstream/18.2.2.tar.xz ceph-upstream/18.2.2.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | examples/rgw/lua/prometheus_adapter.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/rgw/lua/prometheus_adapter.lua b/examples/rgw/lua/prometheus_adapter.lua new file mode 100644 index 000000000..4f0af9a3b --- /dev/null +++ b/examples/rgw/lua/prometheus_adapter.lua @@ -0,0 +1,23 @@ +local http = require("socket.http") +local ltn12 = require("ltn12") + +local respbody = {} +local op = "rgw_other_request_content_length" +if (Request.RGWOp == "put_obj") then + op = "rgw_put_request_content_length" +elseif (Request.RGWOp == "get_obj") then + op = "rgw_get_request_content_length" +end +local field = op .. " " .. tostring(Request.ContentLength) .. "\n" + +local body, code, headers, status = http.request{ + url = "http://127.0.0.1:9091/metrics/job/rgw", + method = "POST", + headers = { + ["Content-Type"] = "application/x-www-form-urlencoded", + ["Content-Length"] = string.len(field) + }, + source = ltn12.source.string(field), + sink = ltn12.sink.table(respbody), +} + |