Connecting Monika with Prometheus

muslim
Hyperjump Tech
Published in
3 min readAug 18, 2021
Monika x Prometheus

Prometheus is an open-source software application that is used for event monitoring. It collects metrics such as requests count, duration and exceptions from applications and records them in a time-series database. Prometheus is also used for monitoring CPU status and memory/disk-space usage so it can be used and be represented in a meaningful display.

Prometheus has become widely known and used in software industries due to its open-source and ease of use. Prometheus is a stand alone and self containing application that run by pulling data from services using worker systems that runs periodically.

Monika on the other hand is a command-line synthetic monitoring application to help you monitor your application by making periodic calls and report back to you if it is having problems or if it has resolved the problems. Monika will always keep you updated about the state of your application.

Why Monika x Prometheus?

Just like Prometheus, Monika is also an open-source application. It is being actively developed and maintained by Hyperjump as an open source application. By making it an open-source application, it means that the application will always be free and you can install it everywhere without worrying about any license or budget.

By marrying Monika with Prometheus, you can display and query Monika’s data beautifully in Prometheus GUI or other data visualization tools like Grafana.

Monika

Install Monika

Monika is developed using Node and typescript, you can install it by using npm or yarn:

$ npm i -g @hyperjumptech/monika# or$ yarn global add @hyperjumptech/monika

or you can use the docker image

docker pull hyperjump/monika

Run Monika

Monika needs a configuration file to make it run. You can generate a configuration file from here, save it as monika.json to the current folder and run this command :

monika -c monika.json --prometheus 3001

If you are using the Docker image, run the following instead :

docker run --name monika \
-p 3001:3001 \
-v ${PWD}/monika.json:/config/monika.json \
--prometheus 3001 \
--detach hyperjump/monika:latest

Prometheus

Install Prometheus

Go to this link for an installation using binary file, you can choose based on your operating system. If you are using the docker image, run the following instead :

docker pull prom/prometheus

Configure Prometheus

Add this line to your Prometheus config :

- job_name: "monika"
static_configs:
- targets: ["localhost:3001"]

Run Prometheus

To start Prometheus with a configuration file, change to the directory containing the Prometheus binary and run :

./prometheus --config.file=prometheus.yml

or for running docker in the background :

docker run -d --name prometheus \
-p 9090:9090 \
-v <PATH_TO_prometheus.yml>:/etc/prometheus/prometheus.yml \
prom/prometheus --config.file=/etc/prometheus/prometheus.yml

Check the data

To check the data, you can open Prometheus web-ui at http://localhost:9090 and run Prometheus query, e.g monika_request_status_code_info.

You can also integrate Prometheus with other data visualization tools like Grafana.

Visualization of Monika Prometheus metrics from a Grafana dashboard

Conclusion

  • Monika and Prometheus is a perfect match that can be easily configured and use in a server.
  • A powerful and free monitoring engine to be used for production-level applications.

Read part two: Visualizing Monika Data with Prometheus and Grafana

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.

--

--