- 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 filemonitors.yaml and place it in the root directory, but neither of these choices are hard requirements.
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:
datafold monitors provision once per file.
Example
Each entry undermonitors: 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. includeandid. The map key is the monitor’s identity.
--dry-run to datafold monitors provision.
FAQ
Can I still create/manage monitors in the app if I'm using monitors as code?
Can I still create/manage monitors in the app if I'm using monitors as code?
Yes, it’s not all or nothing. You can still create/manage monitors in the app even if you’re defining others in code.
What happens to a monitor in the app if it's removed from the code?
What happens to a monitor in the app if it's removed from the 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.Can I use the app to modify monitors managed in code?
Can I use the app to modify monitors managed in code?
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.
Can I export monitors I've created in the app so I can manage them in code?
Can I export monitors I've created in the app so I can manage them in code?
Yes. There are two ways to do this:
- Exporting all monitors: Navigate to the Monitors list page and click the View as Code button
- Exporting a single monitor: Go to the specific monitor and click Actions and then select View as Code
