How to Monitor Supabase with Monosi
Tags: postgres, python, opensource, tutorial
Published: 2022-02-15 22:01:08

Monosi is an [open source data observability](https://monosi.dev) and monitoring platform for data teams (see [Monosi Github](https://github.com/monosidev/monosi)). It is used to quickly set up monitors on a data store to run checks for data quality issues and alert on detected anomalies.

[Supabase](https://supabase.com/) is an open source Firebase alternative. It lets you easily create a backend with a Postgres database, storage, APIs and more.

In this article, we will show you how to set up data observability for Supabase using Monosi. With this setup, you will be able to detect data anomailes that occur in your Supabase instance.

## Prerequisites

For this tutorial, you will need a [Supabase account](https://app.supabase.io/) with a populated database. If you don't have an account, it's quick to get started with their platform by navigating to the [Supabase app](https://app.supabase.io/) and following their [getting started documentation](https://supabase.com/docs/).

You will also need Docker to install and run Monosi. If you're not familiar with Docker, follow the tutorial [here](https://docker-curriculum.com/#introduction). Make sure you have docker installed and ready to use.

## Installing Monosi

Monosi provides a [Docker image](https://hub.docker.com/r/monosi/monosi) to run the web interface and simplify deployment. To install and run Monosi through Docker, run the following command:

```
docker run -p 3000:3000 monosi/monosi
```

_Note: Monosi also has a CLI version distributed through [pypi](https://pypi.org/project/monosi/). More information on how to run Monosi through the CLI can be found [here](https://docs.monosi.dev/introduction/getting-started/cli-as-code)._

## Connecting to Supabase

Since Monosi supports PostgreSQL, it can connect and monitor any Supabase instance.

To get your database credentials from Supabase, navigate to the Settings > Database page and find the Connection info section.

![Supabase connection string](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gylauxh2zi891tyem6ns.png)
 
With the Supabase connection details in hand, navigate to the Monosi datasources page at `http://localhost:3000/settings/sources`. Fill out the Postgres connection details with your respective Supabase instance.

![Monosi PostgreSQL setup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19n4vam1646p67e8jhcm.gif)

## Integrating with Slack

Monosi sends alerts on detected anomalies to Slack. Set up a Slack integration by navigating to `http://localhost:3000/settings/integrations` and creating a new integration with a Slack [channel webhook](https://api.slack.com/messaging/webhooks). More information can be found [here](https://docs.monosi.dev/user-guide/web-app#integrations).

![Monosi integrations page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9nrx7296eb4k50idbknc.png)

## Creating a Monitor

With the Supabase data source and Slack integration connected, we can now create a monitor. Navigate to the Monosi page `http://localhost:3000/monitors` and select the [table health monitor](https://docs.monosi.dev/user-guide/cli/monitors/table-health).

![Monosi monitor creation page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hjw9148onlhmmjpu9pv.png)

Fill out the form with a monitor name, description, and an interval for the monitor to run on (in minutes).

Then, select the Supabase data source and enter the table name that you want monitored. Ensure that this table has a timestamp column. The timestamp column field must be put into the timestamp field.

Save the monitor and it will appear in the monitors index view. This monitor will run until deletion. If any alerts are detected, it will send them to the connected Slack channel.

## Wrapping up

🎉 Congratulations, you've just set up and scheduled a data monitor on your Supabase instance. You can now add more monitors to other tables in your database. Find more information on how to use Monosi [here](https://docs.monosi.dev/).

If you have any questions, join our [Slack community](https://monosi.dev/slack) or open an issue in our repository on [Github](https://github.com/monosidev/monosi). If you want to see more posts like this, [subscribe to our newsletter](https://monosi.dev/community.html)!