Skip to main content
Use an AI agent with Datafold MCP to help generate and manage your monitors YAML configurations.
This is particularly useful if any of the following are true:
  • You have (or plan to have) 100s or 1000s of monitors
  • Your team is accustomed to managing things in code
  • Strict governance and change management are important to you

Getting started

INFOThis section uses GitHub Actions, but the same steps work in any CI system that can run a Python command. Contact us if you need help getting started.

Generate a Datafold API key

If you’ve already got a Datafold API key, use it. Otherwise, you can create a new one in the app by visiting Settings > Account > API keys and selecting Create API Key. The key’s user needs the Edit monitors permission.

Create monitors config

In your repository, create a new YAML file where you’ll define your monitors config. For this example, we’ll name the file monitors.yaml and place it in the root directory, but neither of these choices are hard requirements.
For autocomplete and inline documentation, see the monitors-schema repo. It provides a JSON Schema with setup instructions for VS Code, Cursor, IntelliJ, Neovim, and other editors. Note that Datafold validates this version of the format more strictly than that schema; see Validation.

Add CI workflow

If you’re using GitHub Actions, create a new YAML file under .github/workflows/ using the following template. Be sure to tailor it to your particular setup:
To split a large config, keep one file per asset and run datafold monitors provision once per file.

Example

Each entry under monitors: is keyed by the monitor’s identifier: lower-case letters, digits, underscores, and dashes, starting with a letter or digit. Datafold matches monitors by this key, so keep it stable. Renaming a key creates a new monitor.

Reference

Monitor fields

datadiff fields

Validation

Datafold rejects any key it does not recognize, and names the key in the error. This includes:
  • notifications: monitors do not send notifications yet. Remove the block and check the monitor’s run history instead.
  • Monitor types other than diff (metric, test, schema) and wildcard blocks.
  • include and id. The map key is the monitor’s identity.
To preview changes without applying them, add --dry-run to datafold monitors provision.

FAQ

Yes, it’s not all or nothing. You can still create/manage monitors in the app even if you’re defining others in code.
Nothing. datafold monitors provision creates and updates monitors, but never deletes them, and the --dangling-monitors-strategy flag has no effect. To stop a monitor, set enabled: false and provision again. Monitors managed in code can’t be deleted in the app; to remove one, contact support@datafold.com.
No. Monitors created from code show the banner This monitor is managed in code, and changes must be made in the YAML. They can still be cloned.
Yes. There are two ways to do this:
  1. Exporting all monitors: Navigate to the Monitors list page and click the View as Code button
  2. Exporting a single monitor: Go to the specific monitor and click Actions and then select View as Code
Monitors without an Identifier are left out of the export. Set one in the monitor’s settings first. When you provision a file that uses an existing monitor’s identifier, that monitor becomes managed in code and keeps its run history.

Need help?

If you have any questions about how to use monitors as code, please reach out to our team via Slack, in-app chat, or email us at support@datafold.com.