Cron Job Monitoring for Golang applications

Cron monitoring in Golang #

Oh Dear users can add cron job monitoring to any existing Golang script. When you create a cronjob monitor in your Oh Dear account, you're given a unique pingback URL that should be called every time a cronjob completes.

In this guide, we'll cover how you can implement that in your existing Golang code.

Cron job monitoring in generic Golang #

You can make use of the net/http library for making network calls.

package main

import (
  "fmt"
  "log"
  "net/http"
)

func main() {
    response, _, err := http.Get("https://ping.ohdear.app/e536e771-9ff6")

    if err != nil {
      log.Println('Couldnt ping Oh Dear endpoint')
    }
}

Note: make sure your script stops executing on error conditions, so the http.Get function isn't called even if the script has failed.

Was this page helpful to you? Feel free to reach out via support@ohdear.app or on Twitter via @OhDearApp if you have any other questions. We'd love to help!