Run using Ping Method

Star (0)

This tutorial will show you how to integrate Monika with Ping Method to get your Monika notifications.

Installing Monika

Install Monika via npm install -g @hyperjumptech/monika or if you don’t have NPM in your system, you can download the prebuilt binary from our release page. After installing Monika, run monika -v to verify your Monika installation.

Preparing a configuration

Now that we have installed Monika, let’s prepare a configuration:

- id: desktop
type: desktop
- id: ping_test
name: ping_test
description: requesting icmp ping
interval: 10
- url:
ping: true
- method: GET
- query: response.status != 200
message: Status code is not 200
- query: response.time > 2000
message: Request took more than 2 seconds
incidentThreshold: 1
recoveryThreshold: 1

Let me explain this configuration a little bit:

  • This configuration uses Desktop notifications
  • This probe configuration will do two requests: Hit using PING. After PING success, it will hit using the GET method. If by chance the first request fails, it will not proceed to the next request.
  • This probe configuration will alert you if the status code is not 200, or the request took longer than two seconds
  • This probe configuration will alert you about incidents/recoveries if it happens once, so if there is an incident you will be notified immediately. The same goes if there is a recovery.

Save the configuration above as monika.yaml in your local machine and run monika -c monika.yaml command in your terminal inside the directory where you saved the configuration file.

We’re not finished yet. We want to know what will happen if we failed to PING Google. Let Monika run in the background, and try to disconnect yourself from the internet. You will get a notification:

There is some explanation for the error message:

  • 0: ‘URI not found’
  • 1: ‘Connection reset’
  • 2: ‘Connection refused’
  • 3: ‘Unknown error’
  • 4: ‘Ping timed out’
  • 599: ‘Request Timed out’

It shows PING timed out because your internet is disconnected. So, we could distinguish which alerts come from the API itself, and which alerts come from your internet problem.

PT Artha Rajamas Mandiri (Hyperjump) is an open-source-first company providing engineering excellence service. We aim to build and commercialize open-source tools to help companies streamline, simplify, and secure the most important aspects of its modern DevOps practices.

Copyright © 2023 Hyperjump Tech. All Rights Reserved.