Notification - traefik router name

Hello, does anyone know how I can extract the value of the alerts key "traefik_router_name" and put it in the notification message? My current settings are like this: format: | {{range . -}} {{$alert := . -}} {{range .Decisions -}} {{.Value}} ({{$alert.Source.Cn}}) wird für die nächsten {{.Duration}} gesperrt, da der Alarm „{{.Scenario}}“ von {{$alert.MachineID}} ausgelöst wurde. https://app.crowdsec.net/cti/{{.Value}} {{end -}} {{end -}} Thanks!
6 Replies
CrowdSec
CrowdSec6mo ago
Important Information
This post has been marked as resolved. If this is a mistake please press the red button below or type /unresolve
© Created By WhyAydan for CrowdSec ❤️
iiamloz
iiamloz6mo ago
GitHub
How to parse Traefik router name from an alert · Issue #1348 · cr...
I am using a custom http notification channel that feeds alerts as JSON into VictoriaMetrics. The code looks like this: type: http name: http_victoriametrics log_level: info format: > {{- range ...
iiamloz
iiamloz6mo ago
but in short it should be like:
{{range . -}}
{{$alert := . -}}
{{- $traefikRouters := GetMeta . "traefik_router_name" -}}
{{range .Decisions -}}
{{.Value}} ({{$alert.Source.Cn}}) wird für die nächsten {{.Duration}} gesperrt, da der Alarm „{{.Scenario}}“ von {{$alert.MachineID}} ausgelöst wurde.
https://app.crowdsec.net/cti/%7B%7B.Value%7D%7D

Traefik Routers:
{{range $traefikRouters -}}
- {{.}}
{{end -}}
{{end -}}
{{end -}}
{{range . -}}
{{$alert := . -}}
{{- $traefikRouters := GetMeta . "traefik_router_name" -}}
{{range .Decisions -}}
{{.Value}} ({{$alert.Source.Cn}}) wird für die nächsten {{.Duration}} gesperrt, da der Alarm „{{.Scenario}}“ von {{$alert.MachineID}} ausgelöst wurde.
https://app.crowdsec.net/cti/%7B%7B.Value%7D%7D

Traefik Routers:
{{range $traefikRouters -}}
- {{.}}
{{end -}}
{{end -}}
{{end -}}
se7entynine
se7entynineOP6mo ago
Thanks that worked 🙂
CrowdSec
CrowdSec6mo ago
Resolving Notification - traefik router name This has now been resolved. If you think this is a mistake please run /unresolve
iiamloz
iiamloz6mo ago
Also you can {{range $traefikRouters | uniq -}} to get unique routers

Did you find this page helpful?