Heartbeat Monitoring in Adonis JS Using Acumen Logs

TL;DR

AdonisJS framework tasks, background queues, and scheduled Ace commands can fail silently due to unhandled promise rejections or database disconnects. Because your primary web application remains active, external node pings will not register a backend failure. Setting up heartbeat monitoring allows you to embed a simple HTTP request at the end of your Adonis scheduler logic, alerting your team instantly if a critical background process drops out mid-execution.
Tutorial thumbnail for heartbeat monitoring in AdonisJS web framework using Acumen Logs on a dark background.

Heartbeat monitoring is a simple yet powerful technique to ensure your processes and scheduled tasks are running as expected. By sending periodic “heartbeat” signals to a monitoring service like AcumenLogs, you can track the health of your application’s jobs. If the heartbeat signal fails to arrive within a predefined time frame, Acumen Logs triggers an alert to notify you of potential issues.

In this blog post, we’ll walk you through integrating heartbeat monitoring into an AdonisJS application, specifically within the scheduler, to help you monitor the reliability of your scheduled tasks.

What is Heartbeat Monitoring?

Heartbeat monitoring involves sending a recurring signal (or "pulse") from your application to a monitoring endpoint. This signal indicates that your process is running as expected. If no signal is received within a specified interval, the monitoring service, such as Acumen Logs, will notify you of the issue. This ensures proactive monitoring of background jobs and scheduled tasks.

How to Create a Heartbeat Check in Acumen Logs

  1. 1. Log in to Acumen Logs Dashboard: Start by logging in to your Acumen Logs account.
  1. 2. Navigate to Heartbeat: On the side navigation bar, select the Heartbeat section.
  2. 3. Create a New Heartbeat: Click the Create button, give your heartbeat check an identifiable name (e.g., "Daily Report Task"), and press Save.
  3. 4. Copy the Endpoint: After saving, you’ll be redirected to your Heartbeat dashboard, where you’ll find a unique endpoint for your heartbeat check. Copy this endpoint for use in your application.

Adding a Heartbeat to AdonisJS Scheduler

AdonisJS provides a powerful task scheduler through its @adonisjs/scheduler package. Let’s integrate heartbeat monitoring into a scheduled task.

Step 1: Install the Scheduler Package

If you haven’t already installed the scheduler package, add it to your project:

npm install @adonisjs/scheduler

Step 2: Configure the Scheduler

Ensure the scheduler is enabled in your start/kernel.ts file. It should look like this:

import Scheduler from '@adonisjs/scheduler/build/Scheduler';
import HttpContext from '@ioc:Adonis/Core/HttpContext';

export const kernel = {
 jobs: [Scheduler],
};

Step 3: Add the Heartbeat to Your Task

Inside your scheduler task file (e.g., app/Tasks/HeartbeatTask.ts), use the unique endpoint from AcumenLogs:

import { BaseTask } from '@adonisjs/scheduler/build';
import axios from 'axios';

export default class HeartbeatTask extends BaseTask {
 public static get schedule() {
   return '0 * * * *'; // Runs hourly
 }

 public static get useLock() {
   return false; // Disable locking for this example
 }

 public async handle() {
   try {
     // Send a heartbeat signal to Acumen Logs
     await axios.post('https://acumenlogs.com/heartbeat/xxxx-xxxx-xxxx-xxxx/pulse');
     console.log('Heartbeat sent successfully');
   } catch (error) {
     console.error('Failed to send heartbeat:', error.message);
   }
 }
}

This code sends a POST request to the unique Acumen Logs endpoint, confirming that your scheduler is running as expected.

Step 4: Run the Scheduler

Start the scheduler to ensure your tasks run as expected:

node ace scheduler:run

Once the scheduler is running, you’ll see your heartbeat pulses registered in the Acumen Logs dashboard.

Key Takeaways

  • Standard uptime utilities are completely blind to hidden internal server operations like database backups or automated invoice processing runs.
  • Heartbeat monitoring alerts you when an expected process fails to check in, catching hung background scripts that crash without throwing errors.
  • Integrating a continuous silent handshake pipeline gives your dev team absolute visibility into structural system health beyond basic port accessibility.

Frequently

Asked
Questions

This is the default text value
Up right arrow
How do you implement an uptime check inside an AdonisJS scheduled task framework?
Up arrow icon
You implement it by making a simple asynchronous node-fetch or Axios call to your unique Acumen Logs ping URL at the very end of your task execution loop. If the script logic encounters an error earlier in the pipeline, it terminates before reaching that final function call, prompting our listener platform to immediately flag the missing check-in.

Not seeing the right fit?
Talk to us, we’ll make it work.

Start catching issues before your customers do, with real browser testing, smart alerts and AI-assisted setup.
No credit card required · Free plan available · Cancel anytime
No credit card requiredFree plan foreverCancel anytimeSet up in 60 seconds