This tutorial, we will be sharing how to integrate Monika with Telegram bots so that when there are Monika incidents or recoveries, you will be notified on your Telegram group.
First, you need a Telegram account. Head over to https://web.telegram.org to create your account. And then, create a new private chat. Search for an account named “BotFather”. After that, do these steps below:
Now the next step is to create a group for the Monika notifications. Create a group in Telegram, and invite your bots into the group. Then, set your bot to be a group administrator.
Now that we have our bot API key and set our bot to be a group administrator, all we need to do is get the group ID. Invite one of the following bots into your group to obtain the group ID:
If those bots are not active anymore, you need to find another bot that can obtain the group ID.
After successfully inviting the Telegram Bot Raw, you'll see the group ID. Save this ID somewhere safe and remove the bot from your group. Now that we have the group ID and bot token, we can proceed to integrate it with Monika.
Now that we have our Webhook URL, it’s time to create a configuration called monika.yml
:
notifications:- id: 12f3e1df-3222-4a79-b931-146f964be711type: telegramdata:group_id: "<group_id>"bot_token: <bot_token>probes:- id: 48c828bb-b761-41e7-b360-ba0692ded184name: ''requests:- url: https://github.combody: {}timeout: 10000alerts: []
Let me explain a little bit about this configuration:
notifications
object. There are 3 properties: id
, type
, and data
. Set the id
to any string values, as it is just an identifier. Then, set the type
to telegram
to set the notification channel to Telegram. After that, put your group ID and bot token notifier webhook URL in group_id
and bot_token
keys in the data
object.Now that we have our configuration ready, it’s time to run it with Monika. Go to the directory where you saved the Monika configuration, and run Monika straight away using monika -c monika.yml
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 © 2024 Hyperjump Tech. All Rights Reserved.