Create Notifications For ANYTHING Using Gotify (Crowdsec, Cron Jobs, Scripts, Uptime, File Copy)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody and welcome back to Jim's Garage today we're looking at an awesome application called gotify and this can act as our Central notification server that we can plug in pretty much anything it could be our clone backups it could be scripts that you're running on your server it could be crowdsec alerts it could even be things like uptime Kuma availability statistics or changes and that's just scratching the surface gotify is completely flexible and extensible and as long as it can receive a text message you're pretty much good to go and on top of that gotify not only has a great and responsive user interface it also has a mobile application so you can receive notifications on the go so I'll start by providing a review of the features we'll then go over the configuration and then we'll end up deploying this in Docker now don't worry you can deploy this on pretty much any infrastructure you want to but the docker one is pretty simple so so that's what we'll be doing today once we have it deployed I'll show you a few configuration steps so that you can get some common Services integrated into gotify these will be things like uptime Kuma and crowdsec and I'll also show you how to do a script so it could be something like a simple copy job from one place to another and you want to know when that's completed so heading over to the gotify website we can see some of the standout features it's self-hosted it's free and open source and things like cross-platform and auto updated Docker containers are a real win we can also see a screenshot of the mobile application that's available on Android unfortunately this isn't available on iOS so hopping quickly into the architecture we can see that gotify provides both a rest API and a websocket and it sits between your applications so the things that you want to send notifications and your client I.E what's going to receive the notifications and it will both push and pull messages as specified now the Great thing here is that we can actually set up notifications based upon per application and I'll show you that later on now I recommend installing this using Docker because it's really straightforward it's clearly defined and repeatable and we've seen on the previous page that the images are constantly updated one advantage of the docker installation is that you can configure gotify using environment variables instead of a separate configuration file which will be required if you're going to use a binary so if you head over to my GitHub you'll be pleased to know this is really straightforward to set up and I'll have you up and running in a couple of minutes the first thing we need to do really is to specify the volume where it's going to store some of our persistent data for gotify chiefly the configuration files next you want to specify your time zone just to make sure that the log values sync up and here I'm going to be routing this through my traffic proxy so I can get a proper SSL certificate a nice green tick in my browser and everything's going to be secured if you don't want to use a proxy simply remove the labels section and the proxy section and just add the ports by default this runs on Port 80. so heading over to my Docker VM I've copied the config and tweaked it you'll need to tailor this to your domain if you're using a proxy and also change the ports to something that isn't going to conflict but it should be pretty straightforward so let's jump into deployment so I've navigated to where my Docker compose file is stored and I'm simply going to run sudo Docker compose up Dash D because the image isn't found it's going to go away and pull that and hopefully there aren't any errors and we should be up and running running relatively soon once this is completed I'm going to jump into portana and just check the logs but you could also do that by running sudo Docker logs and then the name of the container so this looks like it's completed without any errors so let's jump into portena so inside portana we can see that the container is healthy let's jump into the logs and just double check that and that all looks good there's no error messages and it says that it's listening on Port 8T so let's go and check that do note that if you're running this through traffic and you set a subdomain for this IE gotify.yourdomain.com you will need to add that to your DNS resolver in my case I've added this to my pie hole installation okay so hopping over into my browser I've gone to gotify.jimsgarage.co.uk and I've been presented with the default login screen now because we didn't specify a default password in the configuration files you can do that if you want we need to log in with the default username and password and that quite simply is admin admin so when we log in it pops up in the bottom left corner and gives you the client name for what logged in and you can keep tabs of this which is really handy for security you can keep control of exactly who has access to it at any time and revoke that if you want to so if you look along the top there's a few options within gotify we have users apps clients plugins admin and log out so users are pretty much what it says on the tin they are the people that you want to have access to This Server so for example the admin that we just created is a user you might want to create different users for different people that you want to give access to you simply click users and then create a new user and you can decide whether they have administrative privileges or not apps is another important feature and I mentioned that earlier in the video so if you click on apps we can create an application now what do I mean by this well as I said before and if we go back to the diagram that was shown each application education that we want to receive notifications for will need to be configured in here so for example we would create an application for crowdsec and we would use that application to send notifications from crowdsec similarly we could set it up for our clone or uptime Kuma or whatever it is that you want to get notifications for simply click create application we'll do one for crowdsec here so go ahead and give it a name a short description if you want and then you can tweak what priority you want to give it now these are Android notification priorities so 10 would be the highest and zero would be lowest and that will determine how it shows up on your notification draw so given that this is crowdsack I'm going to give it a 10 just to give it the highest importance I want to know when an event is triggered on crowdsec so now that crowdsec is created you'll see that it also made a token now we'll need this token when we're creating push messages so what does that mean well it's basically a way for crowdsec to be authenticated this means that only applications that are authenticated I.E these are applications you want to Monitor and you've basically given it a password so it can talk to your server otherwise anything could talk to it something malicious could start bombarding your gotify server and we don't want that so we take this token and we add it into the push message that we're going to configure crowdsec to use and we'll get on to that later in the video as I mentioned in the last video gotify works really well with uptime Kuma and so we're going to create a new application for uptime Kuma and similarly it's going to generate a token and we're going to put that token into uptime Kuma so that we can send notifications to our gotify server and believe it or not just like clockwork as I've been recording loading this video I've had a number of notifications on my Android app that you can see here so it said that the arc server that I set up in the last video is down so creating a new application for uptime Kuma I'm just going to give this one a default priority of five maybe it's less important whichever service it is that you're monitoring we're just going to hit create again and again is created another token and we'll need to copy this token for when we configure it within uptime Kuma lastly I'm going to show you how to do a basic script so that any of the scripts that you're running on your servers these could be batches these could be shells whatever it is cron jobs Etc you can basically create the same process so create an application I'm just going to call this one or clone because I'm going to append the command at the bottom of my all clone script so that when a backup completes it sends me a handy notification telling me the status of that backup things like did it fail did it pass how much data Etc as I said this is completely extensible so you can put as much information into your notification as you want I'm going to give this a lower priority but feel free to tweak this as you need to and there we go we have three applications set up now with their API tokens and we can then go and specify these tokens in the configuration of those notifications quickly jumping into the clients tab you can see that the client is showing up this browser that I'm logged in when you log in from a mobile device it'll also add a client here and any other web browser that you log in with it will show up on here another cool feature of gotify is that it supports plugins now these are basically same as any other plugin these are additional things you can add into gotify to give it additional functionality if we hop over to the GitHub contributions page we can see there's a few plugins there and you may wish to add those if you want to and just having a quick look through there we can see that there's an mqtt plugin there are email plugins and slacks so those could be useful for you and there's a whole load of documentation on the official gotify website if you want to have a go at writing your own plugin so now that we have the basics implemented we've set up a user we've created some applications and we've been given credentials for those you can see on the left here that we now have our different applications and once we receive a notification those would show up in these areas we don't have any because we haven't configured anything now to use them so let's go ahead and do that let's start with crowdsec so heading over to the crowdsec documentation it's really great that gotify is officially supported and there's one prerequisite we need to do first so you can see it here we need to enable the HTTP plugin within crowdsec so if you click on that it's really straightforward we simply need to go into the profiles.yaml and uncomment the HTTP default we then need to create a HTTP yaml if that doesn't already exist at this location specified on the screen once you've done that head back to the previous instructions and we need to copy and paste the following code into that yaml file now what's this going to do well it says it's of type HTTP which is what we just set up we've given it the name HTTP default which is what we specified in the previous screen we're telling it that we want the log level of info and the important bit now is down in the format section so in the format section this is basically the body of the notification and we don't need to make any changes here I'll show you an example of what it will look like when we receive a message when I log into my live gotify instance so basically what it's going to do here is it will show you the IP address of the offender it will show you what type of attack that they try to mount it will provide you with a link to crowdsex Central Intelligence and it will also give you a handy link to Showdown for that IP if you don't know what Showdown is go and check it out I'll put a link in the description the only Parts here that we do need to change or the URL so you'll need to change this to the URL that you specified in your traffic deployment and the important bit where we created the keys using the client you'll need to paste that code into here once you've done that you'll need to save and then redeploy crowdsec and if all goes to well you should be up and running now I've hopped into my live gotify just to give you a demonstration of what this will look like so here you can see that one hour ago I have a ban in place for the following IP address in place for four hours which is the default and you can go and check out my crowdsec video if you don't know what some of this stuff means and there's the links that I mentioned so if I click this it's going to show me all the information that crowdsec has for the IP address typically it's an IP address that's been doing something bad it's been doing lots of Port scans it's been trying to mount lots of attacks Etc but you can find all of the information that crowdsec has on it here you can also see on my live that I've got uptime Kuma running here so in my previous video where we set up a notification for a steam game server you can see that it's just notified me that 17 minutes ago the arc server that I was looking at went down so let's head over into uptime Kuma now and set up notifications for all of your services so back into my production uptime Kuma I'm going to click on the top right I'm going to click settings I'm going to go to Notifications and I'm going to set up a new notification so I click here click on gotify I'm going to put in the application token now that's the token that we created within gotify when we created a new application simply paste that in add your server URL and specify a priority and then just click test or save it really is that simple if everything goes to plan you should receive a notification within your web browser and if you haven't already now might be a good time to go and download the Android application and test that you're receiving notifications on your mobile device now if you're a bit hesitant about setting this up and opening ports to the internet remember you could use a wiregod server to open this up via a VPN this will give you comfort that your gotify server is protected behind a VPN that only you have access to this will give you flexibility to receive notifications on the go and also give you peace of mind that nobody else is going to be able to receive them and as I mentioned we can also integrate go to find notifications into scripts now if anyone's been following my videos cast your mind back to my use of our clone I use this for moving files from my Nas into my Google Drive storage now what would be useful there is for me to know when that's completed and I can do that with this handy notification here so I have a Powershell script here which has the source of the files that I want and the destination so in this case it's just moving files from one location on my Nas to another so this is simply using robocopy to move files from one folder to another there's nothing complicated about that but the bit that we're interested in here is where the dollar sign starts so I've given it a title of our clone completed the message is just that the files are transferred it's got a priority of seven and then here I've specified the client token which we get from the gotify UI and then when this completes it's going to send me a notification to say that it finished successfully now I could tweak that and I could put in a whole host more data things like how many files how quickly it did it whether or any errors Etc but I'm just keeping this simple and giving you an idea of what you can achieve with gotify so hopefully by now you've got gotify up and running it's secured behind your proxy and you're able to start receiving notifications to both your web browser and your mobile device so that you can receive notifications for all of the services that you care about all of the scripts that you're running in the background I've been using gotify for ages and it's really helped me to maintain and manage my home lab let me know how you get on in the comments below tell me about some of the things that you're monitoring in your home lab if you've liked this video please remember to subscribe and comment and I'll see you in the next one take care everybody [Music] thank you
Info
Channel: Jim's Garage
Views: 14,077
Rating: undefined out of 5
Keywords: gotify, notifications, android notifications, homelab, homelab notifications, docker, linux, proxmox, traefik, uptime kuma, rclone, crowdsec, server monitoring, custom notifications, chrome notifications, how to create notifications, create email alert, custom alert, android alert, homelab alert, homelab monitoring, homelab notification
Id: Ft69PY7iitw
Channel Id: undefined
Length: 16min 11sec (971 seconds)
Published: Tue Aug 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.