Monitor n8n Workflows
A scheduled n8n workflow that fails or stops running shows up only in its execution list. To get an alert, end the workflow with an HTTP Request node that pings a Chronos monitor, and report failures from an error workflow.
Ping when the workflow succeeds
Section titled “Ping when the workflow succeeds”- Create a monitor with the same cadence as the workflow’s Schedule Trigger.
- Add an HTTP Request node as the last node of the workflow.
- Set Method to
GETand URL to the monitor’s ping URL, such ashttps://ping.chronos.sh/k3Jx9Qm2TnV7bRw4YcZ8dHfL. - In the node’s Settings, turn on Execute Once, so the node pings once however many items reach it. More than 10 pings a minute to one monitor are rate limited.
- In the same Settings, turn on Retry On Fail, and set On Error to Continue. A lost ping then doesn’t fail the workflow, and the monitor alerts after the grace period instead.
- In the Settings of the node before the ping node, turn on Always Output Data. That node then returns an empty item when it has no data, so the ping node still runs on a night with nothing to process.
The ping node runs only when every node before it succeeded, so a ping means the whole workflow ran.
Report failures
Section titled “Report failures”An error workflow runs when another workflow’s execution fails. The error workflow reports a failure as soon as the execution fails, instead of after the grace period.
- Create a new workflow and add an Error Trigger node.
- Add an HTTP Request node after it. Set Method to
POSTand URL to the ping URL with/failon the end:https://ping.chronos.sh/k3Jx9Qm2TnV7bRw4YcZ8dHfL/fail. - Turn on Send Body and set Body Content Type to Raw. Set Content Type to
text/plainand Body to an expression that carries the error:
{{ $json.workflow.name }}: {{ $json.execution.error.message }}- Save the error workflow. In the monitored workflow’s Settings, set Error workflow to it.
The down alert shows the first 500 characters of the body. Each monitor has its own ping URL, so give each monitored workflow its own error workflow, or route on {{ $json.workflow.id }} with a Switch node.
Check it works
Section titled “Check it works”Run the workflow once by hand. The monitor moves from new to up.
n8n runs an error workflow only when an automatic execution fails, not a manual one. To test the alert, make a node fail, for example an HTTP Request to a URL that doesn’t exist. Let the Schedule Trigger run the workflow, or give it a short schedule for the test.