← Learning center

How can I monitor background processes with Check-ins?

AppSignal Check-ins make it possible to monitor practically any recurring or continuous action within your application, including background jobs like cron jobs and scheduled tasks. In this guide, we'll show you how to use AppSignal Check-ins to optimize the performance of these processes in your application.

What are Check-ins?

Check-ins allow you to monitor background processes like cron jobs or continuous processes:

  • Cron Check-ins monitor cron job executions, ensuring they run on schedule.
  • Heartbeat Check-ins are designed for continuous processes and will notify you if a process stops responding.

AppSignal Check-ins can help you answer questions like:

  • How long do my cron jobs take to execute?
  • Are my background processes functioning as expected?
  • Did a cron job or background process fail?
  • What is the current status of my application's background processes?

Both Cron and Heartbeat Check-ins are designed to notify you of issues, allowing you to avoid silent failures in your critical background tasks and providing an extra layer of performance observability.

What can I monitor with Check-ins?

Check-ins are especially useful for monitoring cron jobs, background jobs, and continuous processes.

In theory, you can monitor anything that can communicate with AppSignal via our integration packages or API. However, we recommend using Check-ins to monitor background processes within your stack where AppSignal can provide you with the insights needed to troubleshoot issues effectively.

For example, if you manage a high-volume application, such as an online store processing thousands of sales each day, you could implement a Heartbeat Check-in every time a purchase is made. This way, AppSignal can alert you if your sales channel falls silent after a specified duration, alerting you to a potential problem within your application or it's integrations.

How can I create a Check-in?

To get started, create a Check-in in the AppSignal app. You can do this by clicking on the Check-ins feature in the AppSignal navigation.

Check-in creation form

Here, you can create a Cron or Heartbeat Check-in and provide all the information AppSignal needs to track your background process for you, such as the following:

  • Identifier: The name of your Check-in, for example weekly_invoice_sync. We advise choosing a clear, descriptive and memorable name.
  • Cron schedule: When creating a Cron Check-in, provide the crontab schedule for that job.
  • Maximum run time: How long AppSignal should wait for a process to complete, so that you can be notified on time for a failed or stalled process.

After creating your Check-ins identifier, keep the name readily available, as you'll need it when configuring your app to send Check-ins.

Handy Check-in helpers

AppSignal's integrations come with built-in helper methods/functions that allow you to monitor background processes with minimal code.

In the example below, you can see how to send Cron Check-ins to AppSignal via our built-in helpers. Here, you'll need to specify the identifier of the Check-in you are tracking.

Elixir
Node.js
Python
Ruby
Elixir
def send_invoices do Appsignal.CheckIn.cron("send_invoices", fn -> # ... your code here ... end) end
Node.js
// Don't forget to import the `checkIn` helpers: import { checkIn } from "@appsignal/nodejs"; function sendInvoices() { checkIn.cron("send_invoices", () => { // ... your code here ... }); } // If the function passed to `cron` returns a promise, the finish event // will be reported to AppSignal if the promise resolves, allowing you // to track the duration of async functions: import { checkIn } from "@appsignal/nodejs"; async function sendInvoices() { await checkIn.cron("send_invoices", async () => { // ... your async code here ... }); } // If the promise is rejected, or if it never resolves, the finish event // will not be reported to AppSignal.
Python
# Don't forget to import the `cron` helper function from the # `appsignal.check_in` module. from appsignal.check_in import cron def send_invoices(): # ... your code here ... cron("send_invoices", send_invoices)
Ruby
def send_invoices() Appsignal::CheckIn.cron("send_invoices") do # ... your code here ... end end

Our Heartbeat helpers enable you to monitor continuous processes with just a few lines of code:

Ruby
Elixir
Node.js
Ruby
loop do Appsignal::CheckIn.heartbeat("job_processor") # ... your code here ... end
Elixir
def job_processing_loop do Appsignal.CheckIn.heartbeat("job_processor") # ... your code here ... job_processing_loop() end
Node.js
// Don't forget to import the `checkIn` helpers: import { checkIn } from "@appsignal/nodejs"; while (true) { checkIn.heartbeat("job_processor"); // ... your code here ... }

To enable continuous Heartbeats, use the { continuous: true } option in the Heartbeat helper method. When continuous is set to true, a heartbeat will be sent to AppSignal every 30 seconds, providing ongoing monitoring of a process's lifespan.

Ruby
Elixir
Node.js
Ruby
Appsignal::CheckIn.heartbeat("job_processor", continuous: true)
Elixir
# This will spawn a new Elixir process, linked to the current process. # If the current process exits, the heartbeat process will also exit. Appsignal.CheckIn.heartbeat("job_processor", continuous: true) # It is also possible to add a continuous heartbeat sending process # to a supervision tree. This will ensure that the process is restarted # alongside the rest of the supervised children. Supervisor.start_link([ {Appsignal.CheckIn.Heartbeat, "my_application"}, # ... other children processes ... ], strategy: :one_for_one)
Node.js
// Don't forget to import the `checkIn` helpers: import { checkIn } from "@appsignal/nodejs"; checkIn.heartbeat("job_processor", { continuous: true });

You can read more about sending Check-ins via helpers in our documentation.

API Requests

You can also monitor Check-ins via our API endpoint, which allows you to create Check-ins for processes beyond your app's codebase.

To perform Cron Check-ins, send a cURL or HTTP request to our Cron Check-in endpoint:

https://appsignal-endpoint.net/check_ins/cron

Below are examples of a Cron Check-in API request using cURL and HTTP:

curl
http
curl
curl -D - -X POST -G 'https://appsignal-endpoint.net/check_ins/cron' \ -d 'api_key=YOUR-APP-LEVEL-API-KEY' \ -d 'identifier=YOUR-CHECK-IN-IDENTIFIER'
http
POST https://appsignal-endpoint.net/check_ins/cron ?api_key=YOUR-APP-LEVEL-API-KEY &identifier=YOUR-CHECK-IN-IDENTIFIER

For Heartbeat Check-ins you can post to the following endpoint:

https://appsignal-endpoint.net/check_ins/heartbeat

Below are two examples of a Heartbeat Check-in API request, one using cURL and the other using HTTP:

cURL
http
cURL
curl -D - -X POST -G 'https://appsignal-endpoint.net/check_ins/heartbeat' \ -d 'api_key=YOUR-APP-LEVEL-API-KEY' \ -d 'identifier=YOUR-CHECK-IN-IDENTIFIER'
http
POST https://appsignal-endpoint.net/check_ins/heartbeat ?api_key=YOUR-APP-LEVEL-API-KEY &identifier=YOUR-CHECK-IN-IDENTIFIER

You can read more about sending Check-ins via API in our documentation.

How can I manage my Check-ins?

The Check-ins overview page allows you to manage and track your application's Check-ins in real-time. Here, you can create, modify, and delete Check-ins and view Check-in occurrence history.

Check-in creation form

Occurrence-level insights make it easy to see how Check-ins are performing and if and when a Check-in has failed, helping you ensure that should things go wrong, you can take corrective action accurately, such as re-running a failed scheduled job.

Check-in creation form

Start monitoring everything with AppSignal

AppSignal has the tools developers need to monitor their applications, giving them timely and critical insights into their app's performance and warning them when things go wrong.

Now that you've learned how you Check-ins can help you monitor your application's background processes, you can:

  1. Read our Check-ins documentation
  2. Read our cron syntax learning center guide
  3. Read our server time learning center guide

Do you have a monitoring-related question our guides don't answer? Let us know, and we'll help you answer it!

Start your free trial

Don’t let the bad bugs bite. Try AppSignal for free.

AppSignal offers a 30-day free trial, no credit card is required. All features are available in all plans. Start monitoring your application in just a few clicks!