--- # # /etc/crowdsec/notifications/discord.yaml # type: http name: discord log_level: info format: | { "embeds": [ { {{range . -}} {{$alert := . -}} {{range .Decisions -}} {{- $cti := .Value | CrowdsecCTI -}} "timestamp": "{{$alert.StartAt}}", "title": "Crowdsec Ban Alert", "color": 16711680, "description": "**Potential Threat Detected.**", "url": "https://app.crowdsec.net/cti/{{.Value}}", {{if $alert.Source.Cn -}} "image": { "url": "https://maps.geoapify.com/v1/staticmap?style=osm-bright-grey&width=600&height=400¢er=lonlat:{{$alert.Source.Longitude}},{{$alert.Source.Latitude}}&zoom=8.1848&marker=lonlat:{{$alert.Source.Longitude}},{{$alert.Source.Latitude}};type:awesome;color:%23655e90;size:large;icon:industry|lonlat:{{$alert.Source.Longitude}},{{$alert.Source.Latitude}};type:material;color:%23ff3421;icontype:awesome&scaleFactor=2&apiKey={{env "GEOAPIFY_API_KEY"}}" }, {{end}} "fields": [ { "name": "Scenario", "value": "{{.Scenario}}", "inline": "false" }, { "name": "IP", "value": "[{{.Value}}]()", "inline": "false" }, { "name": "Ban Duration", "value": "{{.Duration}}", "inline": "false" }, {{if $alert.Source.Cn -}} { "name": "Country", "value": "{{$alert.Source.Cn}} :flag_{{ $alert.Source.Cn | lower }}:", "inline": "false" } {{if $cti.Location.City -}} , { "name": "City", "value": "{{$cti.Location.City}}", "inline": "false" }, { "name": "Maliciousness", "value": "{{mulf $cti.GetMaliciousnessScore 100 | floor}} %", "inline": "false" } {{end}} {{end}} {{if not $alert.Source.Cn -}} { "name": "Location", "value": "Unknown :pirate_flag:" } {{end}} {{end -}} {{end -}} {{range . -}} {{$alert := . -}} {{if GetMeta $alert "target_fqdn" -}} ,{ "name": "target_url", "value": "{{range (GetMeta $alert "target_fqdn" | uniq) -}}`{{.}}`\n{{ end -}}" "inline": "false" } {{end}} {{$alert := . -}} {{range .Meta -}} ,{ "name": "{{.Key}}", "value": "{{ (splitList "," (.Value | replace "\"" "`" | replace "[" "" |replace "]" "")) | join "\\n"}}" } {{end -}} {{end -}} ] } ] } url: https://discord.com/api/webhooks/${DISCORD_WEBHOOK_ID}/${DISCORD_WEBHOOK_TOKEN} method: POST headers: Content-Type: application/json