henrygd / beszel

A lightweight server monitoring hub with historical data, docker stats, and alerts.
MIT License
1.11k stars 45 forks source link

Add support for alerts via shoutrrr #145

Closed parnic closed 6 days ago

parnic commented 2 weeks ago

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:

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: https://github.com/spf13/viper/issues/1895

Fixes https://github.com/henrygd/beszel/issues/71

henrygd commented 2 weeks ago

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 commented 2 weeks ago

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!