Guide to notifications from GrayLog in discord

Hello!

This guide will focus on how to send notifications from the GrayLog logging system to discord, while maintaining a convenient form and complete message content.

It is possible to make a bot that will send messages while maintaining the complete markup of messages and providing them in a human-readable form. Here is an example message:

The advantages regarding SMS notifications are that discord supports markdown markup, which allows you to make a comfortable presentation for submitting a message, and discord is free, which is a plus with a large number of errors in the logs.

There are several ways to set up GrayLog to send messages to discord, they are described in more detail in this open source solution: discord_alerts.

Setting up the bot:

  1. Follow the link and create a bot discord applications (you can add an avatar in one go)

  1. Go to the bot tab and click `add bot`

  1. Press reset token for remote access to the bot and save the token

  1. We go to the URL generator, configure bot access, add the ability to send messages

  1. Open the generated URL in a browser

  1. Copy the link to the channel on the server in the discord application

Fine!

At this point, we should have gone through the following steps:

  • We have a token for the bot

  • We have a channel ID to record messages

  • The bot has been added to the server and is offline

If you did everything right, then these conditions should be met.

Next, we will run an application that accepts logs from GrayLog.

Option 1 – run in docker

The easiest way is to run it through a docker-compose file by simply filling in the fields associated with the token, channel ID and port for http messages. Here is an example yaml file:

version: '3'
services:
discord_alerts:
image: dangdancheg/discord_alerts:latest
ports:
- 3458:3458
environment:
- TOKEN=PASTE_YOUR_DISCORD_TOKEN
- CHANNEL_ID=PASTE_CHANNELID_FROM_CHANNEL_LINK
- PORT=3458

Next, you can simply run the docker compose up command, and the bot is ready.

Option 2 – run in builds

We are looking for the required platform in the following folder build.

Create and populate the .env file.

TOKEN=YOUR_TOKEN
CHANNEL_ID=YOUR_CHAN_ID
PORT=3458

Download the ready-made executable file and save it in the folder with the .env file:

-->    linux/mipsle: discord_alerts
-->       linux/arm: discord_alerts
-->      darwin/386: discord_alerts
-->     freebsd/arm: discord_alerts
-->     freebsd/386: discord_alerts
-->   freebsd/amd64: discord_alerts
-->     openbsd/386: discord_alerts
-->   openbsd/amd64: discord_alerts
-->     windows/386: discord_alerts
-->   windows/amd64: discord_alerts
-->     linux/s390x: discord_alerts
-->      netbsd/386: discord_alerts
-->    netbsd/amd64: discord_alerts
-->      netbsd/arm: discord_alerts
-->  linux/mips64le: discord_alerts
-->    linux/mips64: discord_alerts
-->       linux/386: discord_alerts
-->    darwin/amd64: discord_alerts
-->     linux/amd64: discord_alerts
-->      linux/mips: discord_alerts

We start the file.

Fine! We now have a configured message receiver. Now it remains to configure the graylog output to send messages.

Setting up GrayLog

  1. Go to the Alerts tab:

  1. Open the item with notifications – notifications:

  1. Select http notifications:

  1. Choose any name and add the address for the call (on the specified port and with the / json method)

  1. We should receive the following notification in discord:

If something does not work out, leave comments, I will try to help.

Similar Posts

Leave a Reply Cancel reply