Skip to main content

Monitor your database schema with GitLab CI/CD

Connectivity requirements

In order to function, Atlas must be able to establish a connection to your database. This means you need to ensure that your database is accessible from the GitLab CI/CD runners.

The following guide will quickly walk you through how to get started with Atlas Schema Monitoring in under 5 minutes using the ariga monitor-schema CI Component.

1. Create bot token in Atlas Cloud

Head over to your Atlas Cloud account and click on the top level Monitoring navigation entry. Choose the CD/CD card, choose the GitLab tab, and click on the Generate Token button. Copy the token.


Follow to your GitLab repository and go to Settings -> CI/CD and add a new variable called ATLAS_CLOUD_TOKEN with the value of the token you just copied.

2. Create a new GitLab CI/CD Pipeline for schema monitoring

Save the workflow file below as .gitlab-ci.yml in your repository.

Make sure that DB_URL is stored as a CI/CD variable with the value of your database url or replace $DB_URL with your database url.

Replace the slug with the name you want to give to your database. The slug is used to uniquely identify the database in Atlas Cloud, even when the database URL changes.

stages:
- monitor-schema

include:
- component: $CI_SERVER_FQDN/arigaio/atlas/monitor-schema@~latest
inputs:
stage: monitor-schema
atlas-cloud-token: $ATLAS_CLOUD_TOKEN
url: $DB_URL
slug: gitlab-monitor

Then commit and push the changes to your repository.

3. Set schedule pipeline

Once committed, go to the Build tab in your repository, Go to the Pipeline Schedules tab and click on New Schedule.

After Setting up the schedule, the pipeline will run at the scheduled time. You can also run the pipeline manually by clicking on the Run pipeline button.

After the pipeline runs, it should show you a link to the Atlas Cloud where you can view the schema of your database.

4. View the schema in the Atlas UI

Click on the link provided in the logs to view the schema in the Atlas UI.

Next steps