Skip to content

Slack Webhook Integration

Joseph Huckaby edited this page Aug 24, 2018 · 2 revisions

Cronicle can easily be integrated with Slack Webhooks, so you can be notified via Slack 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 Slack channel. Here are the instructions for setting this up.

First, follow the instructions on the Slack Incoming Webhooks page for creating your own Slack "application" for your team. You can name it "Cronicle" or anything you like.

Create a Slack Webhook and add it to your workspace. Select the desired channel to receive notifications, and click the "Authorize" button. This should give you a custom unique Webhook URL, which will look something like this:

https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

Now, back in Cronicle, you need to decide if you want to enable Slack 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 Slack notifications on, and paste in your Webhook URL here:

Slack Webhook Example

Alternatively, if you opt to enable Slack notifications globally for all events, you simply need to edit your local configuration file (/opt/cronicle/conf/config.json) and paste your Slack Webhook URL into the universal_web_hook configuration property. Example:

{
	"universal_web_hook": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
}

By default, there are four actions that generate a web hook 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 Slack 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 Slack 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 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 Slack Webhooks should then start working immediately. Example:

Slack Notification Example

Clone this wiki locally