Skip to content

Commit eb5c3bd

Browse files
szokeasaurusrexgetsantry[bot]vivianyentran
authored
Monitor upsert support docs (#8500)
* Monitor upsert support docs * [getsentry/action-github-commit] Auto commit * Undoing strange changes my formatter made, idk why * Add tz identifier link Co-authored-by: vivianyentran <20403606+vivianyentran@users.noreply.github.com> * Mention CLI config in requirements * Rename section * Update `--timezone` argument description * [getsentry/action-github-commit] Auto commit --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: vivianyentran <20403606+vivianyentran@users.noreply.github.com>
1 parent bfbb0fb commit eb5c3bd

File tree

1 file changed

+36
-1
lines changed
  • src/docs/product/crons/getting-started

1 file changed

+36
-1
lines changed

src/docs/product/crons/getting-started/cli.mdx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Sentry Crons allows you to monitor the uptime and performance of any scheduled,
1818
To begin monitoring your recurring, scheduled job:
1919

2020
- [Install](/product/cli/installation) the Sentry CLI (min v2.16.1).
21-
- [Create and configure](https://sentry.io/crons/create/) your first Monitor.
21+
- Create and configure your first Monitor in [Sentry](https://sentry.io/crons/create/) or [via the CLI](#creating-or-updating-a-monitor-through-a-check-in-optional).
2222

2323
## Configuration
2424

@@ -59,6 +59,41 @@ sentry-cli monitors run my-monitor-slug -- python path/to/file.py
5959
sentry-cli monitors run my-monitor-slug -- node path/to/file.js
6060
```
6161

62+
### Creating or Updating a Monitor Through a Check-In (Optional)
63+
64+
You can also use the Sentry CLI to create or update your cron monitor when you run your job. This way, you can avoid having to first set up the monitor through the Sentry web interface.
65+
66+
Configure the cron monitor by providing the cron schdule in crontab format using the `--schedule` or the equivalent `-s` argument when executing the `sentry cli monitors run` command. Please make sure to enclose the schedule in quotes, so that your shell parses the argument correctly, like so:
67+
68+
```bash
69+
sentry-cli monitors run --schedule "<expected schedule>" <monitor-slug> -- <command> <args>
70+
```
71+
72+
When providing the `--schedule` argument, we also support the following optional arguments to provide additional configuration:
73+
74+
- `--check-in-margin`: The allowed margin of minutes after the expected check-in time that the monitor will not be considered missed for.
75+
- `--max-runtime`: The allowed duration in minutes that the monitor may be in progress for before being considered failed due to timeout.
76+
- `--timezone`: A valid [tz database identifier string](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) (e.g. "Europe/Vienna") representing the monitor's execution schedule's timezone.
77+
78+
<Alert>
79+
80+
**Known limitation**: When an invalid `--timezone` argument is provided, the command will silently fail to create/update the cron monitor. Therefore, when using this argument, please:
81+
82+
- Ensure you are using a valid tz database identifier string when using this argument, and
83+
- Verify that the cron monitor was created successfully in Sentry after running the command.
84+
85+
</Alert>
86+
87+
Below are some usage examples:
88+
89+
```bash {tabTitle: Every Minute}
90+
sentry-cli monitors run -s "* * * * *" -- my-command
91+
```
92+
93+
```bash {tabTitle: Every Hour (+ Optional Arguments)}
94+
sentry-cli monitors run -s "0 * * * *" --check-in-margin 10 --max-runtime 5 --timezone "Europe/Vienna" -- my-command
95+
```
96+
6297
### Specifying Monitor Environments (Optional)
6398

6499
If your cron monitor runs in multiple environments you can use the `-e` flag to specify which [Monitor Environment](/product/crons/job-monitoring/#multiple-environments) to send check-ins to.

0 commit comments

Comments
 (0)