Push TrueNAS/FreenAS alerts to Alerta

FreeNAS (and TrueNAS) keep track of system alerts and can be configured to send those out via email and a few other services such as Slack and InfluxDB. The selection of these services is pretty limited. Especially limiting is the fact that it does not provide a way to call a custom script or a web service endpoint. But we can capture the alerts from the system and get them out in a roundabout way.

Use FreeNAS middleware client to push alerts from Freenas to Alerta

TrueNAS/FreeNAS does not have a plugin for Alerta, nor does it have a facility to use shell scripts or http/json for alerts.

I wrote a simple script that takes the alerts from the FreeNAS database using the included middleware client midclt and pushes them to the Alerta endpoint using curl, making some assumptions along the way.

Currently the script just invokes FreeNAS provided CLI tool midclt to get the info about ALL alerts without keeping track of their status and pushes them into Alerta. Alerta can take care of duplicates so this is not a big issue.

The freenas-alerta script uses midclt, jq and wget which are all included on a TrueNAS install.

Without going into details, what you have to do is to put freenas-alerta.sh and .secrets in Add FreeNAS/TrueNAS Cron task as:

cd /<PATH TO SOME LOCATION>/bin/cron && /bin/bash ./freenas-alerta.sh

The script is available on GitHub at the url below. You can modify it to do something else rather than pushing the alerts to Alerta.

258 Words

2021-09-21 00:00 +0000

How to integrate Alerta alerts with Zulip

Zulip (https://zulip.com) is an open source messaging system that has a unique threaded chat model with topics for threads. Alerta (https://alerta.io) is on open source alert management tool that aggregates alerts from various sources and displays them on an easy to use web interface.

In addition to displaying alerts, Alerta can also be set up to send notifications to various external tools such as Telegram and Slack. At the moment there is no explicit way to send the alerts to Zulip instead. However, Zulip does support Slack style incoming webhooks as a compatibility feature through which we can push notifications to Zulip streams (like channels or chat rooms in Zulip lingo).

Please refer to the documentation on how to install and use Zulip1 and Alerta2 if you don’t already have them running. You also have to create a Zulip bot to be able to receive incoming webhooks from Alerta.

Once you have your Zulip bot (with its API key) and you have enabled the Slack plugin3 in Alerta, all you have to do is set the SLACK_WEBHOOK_URL as in the example below:


For testing make sure you’re logged into Zulip with your usual user and joined the stream you have configured above to see the incoming messages. After that all you have to do is either send Alerta a fake alert using its JSON API or wait for one of your services to fail and create an alert.

  1. Zulip’s Slack style incoming webhook documentation: https://zulip.com/integrations/doc/slack_incoming ↩︎

  2. Alerta documentation: https://docs.alerta.io ↩︎

  3. Alerta Slack plugin: https://github.com/alerta/alerta-contrib/tree/master/plugins/slack ↩︎