# HG changeset patch # User Kim Alvefur # Date 1626431254 -7200 # Node ID ebc2c099a11bac9e716f18bb0cd0fda15c7de981 # Parent 9b253cce7d88cd596994cc745743f7108b9fe934 mod_pubsub_alertmanager: Allow templating the pubsub node to publish to Allows e.g. using a pubsub node per alert severity, or per some other category. diff -r 9b253cce7d88 -r ebc2c099a11b mod_pubsub_alertmanager/mod_pubsub_alertmanager.lua --- a/mod_pubsub_alertmanager/mod_pubsub_alertmanager.lua Fri Jul 16 12:26:55 2021 +0200 +++ b/mod_pubsub_alertmanager/mod_pubsub_alertmanager.lua Fri Jul 16 12:27:34 2021 +0200 @@ -26,6 +26,8 @@ return 202; end +local node_template = module:get_option_string("alertmanager_node_template", "{path?alerts}"); + function handle_POST(event, path) local request = event.request; @@ -49,7 +51,8 @@ item:tag("link", { href=alert.generatorURL }):up(); end - local ret = publish_payload(path, request.ip, uuid_generate(), item); + local node = render(node_template, {alert = alert, path = path, payload = payload, request = request}); + local ret = publish_payload(node, request.ip, uuid_generate(), item); if ret ~= 202 then return ret end @@ -91,5 +94,6 @@ module:provides("http", { route = { ["POST /*"] = handle_POST; + ["POST"] = handle_POST; }; });