← Back to Docs

Get started with heartbeat monitoring

Monibot monitors heartbeats from cron jobs, systemd timers, background tasks and applications. Use it to ensure that

  • hourly backup jobs run successfully.
  • your CI/CD pipeline builds your app regularly (say, each night).
  • your applications' background tasks run periodically and successfully.

This page shows you how to get started with heartbeat monitoring.


Create a watchdog in Monibot

  • Log into your Monibot account. If you don't have one, register now, it's free.
  • In the main menu, click on the 'Watchdogs' link. Here you'll see a 'New Watchdog' button.
  • Click the 'New Watchdog' button and enter the data for your heartbeat watchdog:
    • The name, for example 'Database backup'. You can chose any name here, it's used only for display.
    • The heartbeat interval, for example '24h'. This is the interval you expect the heartbeat to come in.
  • Click 'Save'. Your watchdog is now ready and will listen for heartbeats. Please note that we've allocated a unique id for your watchdog. You will need that id in the next step.

Send heartbeats from your server or application

After you have successfully created a watchdog, you are now ready to send heartbeats from your server or application to Monibot. For that, you have a number of options:

  • With our moni command line tool.
  • With curl.
  • With our Go SDK.
  • With any HTTP library of your choice.

Send heartbeats with our moni command line tool

You can use our moni command line tool to send heartbeats from the command line.

export MONIBOT_API_KEY=0000000000000000   # insert API key here
export WATCHDOG_ID=0000000000000000       # insert watchdog ID here
moni heartbeat $WATCHDOG_ID

There are two variables you have to include in the moni invocation:

  • MONIBOT_API_KEY. This is your API key. You can find it on your account profile. While you can set the API key directly in the invocation, it's a good practice to set it as an environment variable. If you do as shown above, moni will pick it up from the environment.
  • WATCHDOG_ID. This is the ID of the watchdog you want to send a heartbeat for.

Send heartbeats with curl

You can use curl to send a heartbeat from the command line.

export MONIBOT_API_KEY=0000000000000000   # insert API key here
export WATCHDOG_ID=0000000000000000       # insert watchdog ID here
curl -X POST https://monibot.io/api/watchdog/$WATCHDOG_ID/heartbeat \
    -H "Authorization: Bearer $MONIBOT_API_KEY"

There are two variables you have to include in the curl invocation:

  • MONIBOT_API_KEY. This is your API key. You can find it on your account profile.
  • WATCHDOG_ID. This is the id of the watchdog you want to send a heartbeat for.

Send heartbeats with our Go (golang) SDK

You can use our Go SDK to send heartbeats programmatically.

const (
    apiKey = "0000000000000000"       // insert API key here
    watchdogId = "0000000000000000"   // insert watchdog ID here here
)

func main() {
    // initialize api
    api := monibot.NewApi(apiKey)
    // send a watchdog heartbeat
    api.PostWatchdogHeartbeat(watchdogId)
}

Send heartbeats with any HTTP library of your choice

You can use any HTTP library to send heartbeats programmatically. Here's a Python example:

import requests;

apiKey = '0000000000000000'        // insert API key here
watchdogId = '0000000000000000'    // insert watchdog ID here here

# send POST request
response = requests.post(
    url = 'https://monibot.io/api/watchdog/' + watchdogId + '/heartbeat',
    headers={ 'Authorization': 'Bearer ' + apiKey },
)

# print response
print (response)

# Output: <Response [200]>




If you have a question that is not covered by our docs, please feel free to contact us, we are happy to help.









Made and hosted in Germany
© monibot.io