Skip to main content

Defining Monitors as Text Files

This page showcases how to create and edit Monitors with the CLI.

Just like other structures of Tracetest, you can also manage your Monitors using the CLI and definition files.

A definition file for a Monitor looks like the following:

type: Monitor
spec:
id: "abcdef" # optional
name: Sample Monitor
enabled: true
variableSetId: ""
tests:
- ./tests/create-product.yaml
- ./tests/add-product-to-cart.yaml
- ./tests/complete-purchase.yaml
- testID # you can also reference tests by their ids instead of referencing the definition file
testSuites:
- ./tests/create-product-suite.yaml
- testSuiteID # you can also reference tests by their ids instead of referencing the definition file
schedule:
cron: "0 0 0 0 *"
alerts:
id: ""
type: webhook
webhook:
url: https://...
method: POST
body: '{"text": "Monitor {{ .Monitor.name }} failed."}'
events:
- FAILED

In order to apply this Monitor to your Tracetest instance, make sure to have your CLI configured and run:

tracetest apply monitor -f <monitor.yaml>

If the file contains the property spec.id, the operation will be considered a Monitor update.

To return a list of Monitors, run:

tracetest list monitor

[Output]
ID NAME VERSION RUNS LAST RUN TIME LAST RUN STATE URL
----------- ---------------- --------- ------ --------------------- ---------------- --------------------------------------------
123456789 Sample Monitor 1 120 2024-06-27 13:00:01 https://api.tracetest.io/monitor/123456789