DRuggeri / alertmanager_gotify_bridge

A bridge between Prometheus AlertManager and a Gotify server
Apache License 2.0
65 stars 9 forks source link

Function not defined error #33

Closed cyxou closed 5 months ago

cyxou commented 8 months ago

Hi! First of all, thanks for this awesome bridge - really useful tool)))

I am configuring my templates trying to replace GeneratorURL host with my company public domain and whatever function I tried to use (stripDomain, stripPort, replace, reReplaceAll) it always throws an error like function "<funcName>" not defined. Here is a simple expression from one of my templates:

{{ if (.GeneratorURL) }}👉[Alert details]({{ replace .GeneratorURL "http://vmalert-vm-victoria-metrics-k8s-stack-599dbcd7db-mfb76:8080" "https://vmalert.mycompany.com" }})  {{- end }}

Is it even possible to use those functions in templates?

DRuggeri commented 8 months ago

Hey there, @cyxou - sorry for the slow reply! Yes, those look like they should work fine. I think this is caused by not including the Prometheus functions in the very first template rendering attempt. I've tweaked it and am adding a new release, but can you test and let me know if it works as you have it configured?

If it doesn't, I'd like to hear more about how your configuration is structured such as file locations/contents, debug logs, etc.