Description
Problem Statement
To cleanly integrate with frameworks like Celerybeat, Sidekiq, and Laravel's cron monitoring, we want to be able to easily and automatically register monitors. There are two different scenarios for automatically registering these:
- Within the framework where we have a majority of configuration available (e.g. we know the schedule already)
- Outside of the framework, where we want a convenience method to create a monitor without a GUID mapping
Basically in both situations we want to be able to upsert and reference a monitor without storing an internal GUID mapping, as both situations are effectively stateless.
Solution Brainstorm
Ignoring our current APIs, you could imagine something akin to:
POST /monitors/checkins/ {"monitor": {"name": "my-unique-name", "schedule": "* * * * *"}, "status": "ok"}
Effectively allowing you to specify and define the monitor in the same payload as the check-in. Now this could work but its still a fairly heavy payload to craft, especially when we're talking about crontab and curl.
What we'd love to achieve is something like:
curl -x POST https://myorg.sentry.io/api/monitors/my-unique-name/checkins/ -d '{"status": "ok"}'
The benefit here is this is minimal JSON (less error prone), but the issue is my-unique-name
needs to be:
- unique organization wide
- encoded into the url
Alternatively we could have a shortened API using a few more HTTP standards, such as query params, and opening it up to a GET request akin to a webhook:
curl https://myorg.sentry.io/hooks/monitors/checkin/?id=my-unique-name&status=ok
From a framework level, no matter the API, we'd effectively call some variation of this upsert endpoint when we send a check-in. Meaning whenever a Celerybeat task runs, we'd also send along the monitor details (or worst case, we'd make a second API call to ensure the monitor is created).
The last item here to note is, what do we do if we dont have a schedule? Do we support creating (upserting) a monitor without one? We could. We would then either need to prompt the user for configuration in the UI, or we could try to automatically learn the schedule after a few runs.
Refs #42283
Metadata
Metadata
Assignees
Labels
Type
Projects
Status