-
Notifications
You must be signed in to change notification settings - Fork 389
Discord Webhook Integration
Cronicle can easily be integrated with Discord Webhooks, so you can be notified via Discord message when jobs are started, completed, and or fail. The notifications contain the event title, a description of the action, and a detail URL, and can be targeted at any Discord channel. Here are the instructions for setting this up.
First, follow the instructions on the Discord Intro to Webhooks page for creating your own Discord webhook for your channel. You can name it "Cronicle" or anything you like.
Create a Discord Webhook by going to Server Settings, then Integrations, then Webhooks. Select the desired channel to receive notifications, and click the "Copy Webhook URL" button. This should give you a custom unique Webhook URL, which will look something like this:
https://discord.com/api/webhooks/10984376568262/raHD8YolEM-d6jG1Ru4CwbVbG-nm-Me2DHGW0XE
Now, back in Cronicle, you need to decide if you want to enable Discord Webhook notification per event, or universally for all events. If you decide to enable it for only some events, you can do everything via the UI. Simply edit the events you want to enable Discord notifications on, and paste in your Webhook URL here:
Alternatively, if you opt to enable Discord notifications globally for all of your events, you simply need to edit your local configuration file (/opt/cronicle/conf/config.json
) and paste your Discord Webhook URL into the universal_web_hook configuration property. Example:
{
"universal_web_hook": "https://discord.com/api/webhooks/10984376568262/raHD8YolEM-d6jG1Ru4CwbVbG-nm-Me2DHGW0XE"
}
By default, there are four actions that generate a webhook notification. A job starting (job_start
), a job completing successfully (job_complete
), a job failing (job_failure
), and a scheduler error, i.e. unable to launch job (job_launch_failure
). You can customize which of these should call your web hook, and customize the Discord message text as well, by changing the web_hook_text_templates configuration object. Example:
"web_hook_text_templates": {
"job_start": "Job started on [hostname]: [event_title] [job_details_url]",
"job_complete": "Job completed successfully on [hostname]: [event_title] [job_details_url]",
"job_failure": "Job failed on [hostname]: [event_title]: Error [code]: [description] [job_details_url]",
"job_launch_failure": "Failed to launch scheduled event: [event_title]: [description] [edit_event_url]"
}
If you want to disable any of the four notification actions, simply remove the corresponding keys. For example, if you don't want a Discord notification for a job starting, simply remove the job_start
key. You can also alter the message text here as well. See the web_hook_text_templates docs for details on the macro system.
When you are done making changes to the config.json
file, restart Cronicle by typing: /opt/cronicle/bin/control.sh restart
.
Your Discord Webhooks should then start working immediately. Example: