Skip to main content

Monitor your database schema with Bitbucket Pipelines

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 Bitbucket Pipelines 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 Pipleine.

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 Bitbucket tab, and click on the Generate Token button. Copy the token.


Follow to your Bitbucket repository and go to Repository settings -> Pipelines -> Repository variables and add a new variable called ATLAS_CLOUD_TOKEN

2. Create a new Bitbucket Pipeline for schema monitoring

Save the workflow file below as bitbucket-pipelines.yml in your repository.

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

Replace the ATLAS_INPUT_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.

image: atlassian/default-image:3
pipelines:
custom:
monitor-schema:
- step:
name: "Monitor your database schema"
script:
- name: "Monitor schema"
pipe: docker://arigaio/atlas-action:v1
variables:
ATLAS_ACTION: "monitor/schema"
ATLAS_INPUT_CLOUD_TOKEN: ${ATLAS_CLOUD_TOKEN}
ATLAS_INPUT_URL: ${DB_URL}
ATLAS_INPUT_SLUG: "bitbucket_monitoring" # optional
- source .atlas-action/outputs.sh
info

If your database URL is defined inside atlas.hcl file, you can use the ATLAS_INPUT_CONFIG instead of ATLAS_INPUT_URL. For more information, see the Bitbucket Pipes documentation.

              variables:
ATLAS_ACTION: "monitor/schema"
ATLAS_INPUT_CLOUD_TOKEN: ${ATLAS_CLOUD_TOKEN}
- ATLAS_INPUT_URL: ${DB_URL}
+ ATLAS_INPUT_CONFIG: "file://atlas.hcl"
+ ATLAS_INPUT_ENV: "dev"

Then commit and push the changes to your repository.

3. Set schedule pipeline

Once committed, go to the Pipelines tab in your repository, Click on Schedules and click on New schedule. Select the monitor-schema pipeline you just created and set the schedule to run at your desired frequency.

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