Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for alerts via shoutrrr #145

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

parnic
Copy link
Contributor

@parnic parnic commented Sep 1, 2024

This provides users the ability to use a wide variety of notification platforms instead of just email. If there's a problem sending a notification via shoutrrr, an error is logged and email is attempted as a fallback.

Since this uses Viper, users can set a notification type and URL via either a config file or environment variable. In the beszel_data folder (where the sqlite dbs reside), create an alerts.env file to set values that way.

Values:

  • NOTIFICATION_TYPE
    • If this is shoutrrr, then the shoutrrr library is used. Any other value, including not being set, uses the fallback email behavior.
  • NOTIFICATION_URL

Note: there's currently a bug in viper v1.18.2+ where environment variable overrides aren't functioning when no config file exists, so this library should remain pinned to 1.18.1 until that's fixed. See: spf13/viper#1895

Fixes #71

@henrygd
Copy link
Owner

henrygd commented Sep 1, 2024

Thanks!

shoutrrr does look like a great option for this, assuming it doesn't add much overhead.

However, I want to allow users to add their own notification URLs. So I'd rather build the config into the web UI than pull global values from a file.

I'm working on adding support for multiple disks and should have that release out in the next few days. As soon as that's finished, I'll pull your changes and test it out.

If it looks like it's going to work, I'll merge this and adapt it for the following release.

@parnic
Copy link
Contributor Author

parnic commented Sep 1, 2024

Sounds perfect. I'd love to have this support in my current docker installation of Beszel, which has been awesome so far. I agree some UI configuration would be preferred, but this felt like a first step toward that.

Thanks for taking a look!

This provides users the ability to use a wide variety of notification platforms instead of just email. If there's a problem sending a notification via shoutrrr, an error is logged and email is attempted as a fallback.

Since this uses Viper, users can set a notification type and URL via either a config file or environment variable. In the beszel_data folder (where the sqlite dbs reside), create an alerts.env file to set values that way.

Values:
* NOTIFICATION_TYPE
  * If this is `shoutrrr`, then the shoutrrr library is used. Any other value, including not being set, uses the fallback email behavior.
* NOTIFICATION_URL
  * If NOTIFICATION_TYPE is shoutrrr, this is the URL given to shoutrrr to send the alert. See list of supported services: https://containrrr.dev/shoutrrr/services/overview/

Note: there's currently a bug in viper v1.18.2+ where environment variable overrides aren't functioning when no config file exists, so this library should remain pinned to 1.18.1 until that's fixed. See: spf13/viper#1895

Fixes henrygd#71
@parnic parnic force-pushed the add-shoutrrr-support branch from e0618e3 to 5d50f94 Compare September 6, 2024 18:47
@henrygd henrygd merged commit 99d79f7 into henrygd:main Sep 9, 2024
@parnic parnic deleted the add-shoutrrr-support branch September 9, 2024 18:20
@henrygd
Copy link
Owner

henrygd commented Sep 16, 2024

Finally pushed this out in 0.4.0. There's a settings page now where you can add shoutrrr URLs.

Thanks again for your contribution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Webhook alerts / push notifications
2 participants