调试 alertmanager webhook

Debug alertmanager webhook

我用的是rancher 2.5提供的监控app,实际上是在安装kube-prometheus-stack Helm chart。我正在尝试使用 webhook 作为接收者发送警报。 Webhook 位于自定义服务上,记录它使用 http 400 响应请求。我的问题是如何查看发送到提供 Webhook 的服务器的请求 alertmanager。我是 运行 带有 log.level=debug 的 pod,但我看到的唯一日志是:

level=debug ts=2021-01-11T17:22:32.629Z caller=notify.go:685 component=dispatcher receiver=prometheus integration=webhook[0] msg="Notify success" attempts=1
level=debug ts=2021-01-11T17:23:02.591Z caller=dispatch.go:138 component=dispatcher msg="Received alert" alert=Watchdog[7109567][active]
level=debug ts=2021-01-11T17:23:32.594Z caller=dispatch.go:473 component=dispatcher aggrGroup="{}/{severity=~\"^(?:warning|none|critical)$\"}:{}" msg=flushing alerts=[Watchdog[7109567][active]] 

这不是很有帮助,我想看看实际的请求和响应。

所以我设法解决这个问题的方法是将 webhook 发送到实际上 运行 netcat -l 的中间服务器,然后我将请求复制到实际目的地。

k8s 的唯一替代方案是 运行:https://github.com/eldadru/ksniff

遗憾的是我没有找到更好的解决方案。