Monitor your server with Monika using TCP requests
When we initially developed Monika, we only have one big picture: we do HTTP requests to a server and check if the server is working properly or not. Along the way, we found out that there are more cases that we have to cover, one of which is TCP requests.
How do TCP and HTTP relate to each other? To put it simply, before a client and a server can exchange an HTTP request/response, both of them must establish a TCP connection first. So, HTTP requests must rely on TCP to work properly.
In the newest version of Monika, we have implemented how to probe a URL using TCP instead of HTTP so that we can confirm that the server is working before we send the real request body of our endpoints.
This article will show you how to monitor your server using TCP requests in the newest version of Monika. So, without further ado:
GitHub - hyperjumptech/monika: Monika is a command-line application to monitor every part of your…
Monika is a command-line application to monitor every part of your web app using a simple YAML configuration file. Get…
Monika is an open-source and free synthetic monitoring command-line application. The name Monika stands for “Monitoring Berkala”, which means “periodic monitoring” in the Indonesian language.
With Monika, you can add as many websites as you want to monitor. You can monitor several undesirable events such as service outages or slow services. In addition, you can configure Monika to send notifications of the incidents on your services through your favorite communication tools like SMTP mail, Telegram, Slack, Facebook Workplace, etc.
There are three ways to install Monika:
- Install using npm or yarn (Windows/Linux/Mac)
If you’re using NPM or Yarn, you can simply run this command in your terminal:
npm i -g @hyperjumptech/monika
yarn global add @hyperjumptech/monika
- Install script
If you are using Linux, you can simply run this command in your terminal:
Now that we have our Google Chat Webhook URL and installed Monika, it’s time to create a configuration called
- Use Package Managers such as Chocolatey or Snapcraft
Now that we have installed Monika in our system, it’s time to create the Monika TCP requests configuration:
Let me explain a little bit about this configuration:
- This configuration uses the Desktop notification
- This configuration uses TCP mode, with the host
3000, and data
Hello from Monika
- Because there is no incident or recovery threshold defined, it will use the default value, which is five times.
If we compare the TCP requests configuration with the usual HTTP requests configuration, you can see the difference lies between the
socket key and the
If you define the
socket key it means your probe will be using TCP connections, which only uses
port , and
data value. Otherwise, if you define the
requests key it means your probe will be using HTTP requests.
Save the file below as monika.yml and test the configuration by running
monika -c monika.yml in your terminal. As an example, I run a simple server in my localhost at port 3000:
Congratulations! You have successfully monitored your server using Monika with TCP requests!
TCP requests can be handy as secondary proof to check if your server is working or not. Sure, we have implemented hitting the STUN servers periodically to confirm that the internet is working, but it’s better to be safe than sorry.
Don’t forget that this feature is only available in the latest version (v.1.7.0). If you haven’t updated your Monika, you cannot use this feature.
If you’re having a problem with using Monika, don’t hesitate to create an issue on Monika’s Github Issue Page. If you like this article, don’t forget to clap and share this article with your friends!
That’s it for today, see you next time!
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 their modern DevOps practices.