Skip to content

Commit

Permalink
Merge pull request #9 from sachasmart/updateReadMe-09-14-2023
Browse files Browse the repository at this point in the history
Update Readme and Environment
  • Loading branch information
rogerrum authored Oct 25, 2023
2 parents e97b368 + cf54975 commit 8d5a28f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ Give this a webhook (with the DISCORD_WEBHOOK environment variable) and point it
## Environment configuration variables
```properties
DISCORD_WEBHOOK=<webhook, where to post alerts. For more details see: https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks>
DISCORD_USERNAME=<override bot name at Discord (optional)>
DISCORD_USERNAME=<override bot name at Discord>
DISCORD_AVATAR_URL=<override avatar url at Discord (optional)>
LISTEN_ADDRESS=<address and port to listen on (default:127.0.0.1:9094)>
VERBOSE=ON <(Optional - logs request and response)>
```

Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ func checkWebhookURL(webhookURL string) {
log.Printf("The Discord WebHook URL doesn't seem to be valid.")
}
}
func checkDiscordUserName(discordUserName string) {
if discordUserName == "" {
log.Fatalf("Environment variable 'DISCORD_USERNAME' or CLI parameter 'username' not found.")
}
_, err := url.Parse(discordUserName)
if err != nil {
log.Fatalf("The Discord UserName doesn't seem to be a valid.")
}
}

func sendWebhook(alertManagerData *AlertManagerData) {

Expand Down Expand Up @@ -326,6 +335,7 @@ func sendRawPromAlertWarn() {
func main() {
flag.Parse()
checkWebhookURL(*webhookURL)
checkDiscordUserName(*username)

if *listenAddress == "" {
*listenAddress = defaultListenAddress
Expand Down

0 comments on commit 8d5a28f

Please sign in to comment.