Skip to content

feat(uptime): Create uptime monitors through the detectors endpoint - #1837

Draft
sentry-junior[bot] wants to merge 1 commit into
mainfrom
feat/uptime-create-via-detectors
Draft

sentry-junior[bot] wants to merge 1 commit into
mainfrom
feat/uptime-create-via-detectors

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

create_uptime_monitor posted to the legacy POST /projects/{org}/{project}/uptime/ endpoint. That endpoint goes through create_uptime_detector, which never sets Detector.created_by_id. As a result, every uptime monitor an agent creates through the MCP has no creator. The Sentry UI uses POST /organizations/{org}/projects/{project}/detectors/ (UptimeDomainCheckFailureValidator). That path sets created_by_id=acting_user_id(request.user).

This switches the create call to the detectors endpoint and sends the same payload shape the UI sends (type: uptime_domain_failure, with check settings in dataSources[0] and environment and the thresholds in config). Monitors created this way record the OAuth user as their creator, so warehouse data can tell MCP-created monitors apart from monitors with no creator. Right now those make up most of the recent rise in manual uptime monitor creation.

The tool's input and output don't change. After the create, the client fetches the monitor from the existing uptime details endpoint (detector id == uptime monitor id), so the response keeps the same UptimeMonitor shape that the find, get and update tools use.

Two behavior differences on the server side, worth a look from the uptime/ACI owners:

  • UptimeDomainCheckFailureValidator.create always calls enable_uptime_detector(..., ensure_assignment=True), and the base validator doesn't pass enabled through on create. A requested status: "disabled" is therefore applied with a follow-up legacy PUT … {status: "disabled"}.
  • The legacy create_uptime_detector path turns off org uptime autodetection and deletes onboarding monitors when a manual monitor is created. I didn't find that logic in the detector validator path. That would match what the UI does today, but someone who owns this code should confirm it's intended.

Not verified against a live org yet. The tests use MSW mocks shaped from the Sentry source.

via @mrduncan.

--

View Session [Sentry]

The legacy POST /projects/{org}/{project}/uptime/ endpoint does not record
who created the monitor, so MCP-created monitors show up with no creator.
Create them through the project detectors endpoint the Sentry UI uses, which
records the acting user, then return the monitor in the existing uptime shape.

Co-Authored-By: Matt Duncan <14761+mrduncan@users.noreply.github.com>
@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 3, 2026 12:28am UTC

Request Review

@sentry-junior

sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Related: #1846 adds create_monitor for cron monitors, and it currently posts to the legacy POST /organizations/{org}/monitors/ endpoint. That path has the same missing Detector.created_by_id problem this PR fixes for uptime (ensure_cron_detector never sets it). I asked #1846 to create through the detectors endpoint (type: monitor_check_in_failure) instead, so the two PRs should end up using the same pattern.

@sentry-junior

sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: the cron version of this fix is in #1861. It creates cron monitors through the project detectors endpoint, the same way this PR does for uptime monitors, and supersedes #1846.

dcramer pushed a commit that referenced this pull request Nov 3, 2026
Fixes #1845. This supersedes #1846: it keeps @Chipagosfinest's commits
for the `create_monitor` tool and adds a fix on top, applied from that
PR's review.

`create_monitor` lets agents create cron monitors instead of sending
users to the UI. It's catalog-only, gated by the `project-management`
skill, and takes the same schedule, timezone, margin, runtime and
threshold inputs as in #1846.

What changed from #1846:

- **It creates through the detectors endpoint.** It now calls `POST
/organizations/{org}/projects/{project}/detectors/` with `type:
monitor_check_in_failure`, the same payload the cron UI sends
(`cronFormDataToEndpointPayload`). The legacy `POST
/organizations/{org}/monitors/` path creates the detector through
`ensure_cron_detector`, which never sets `created_by_id`, so monitors
created through MCP would have had no creator. This is the same gap
#1837 fixes for uptime monitors. The detector path also matches
`create_metric_monitor`, so the tool now accepts optional `workflowIds`
to connect existing Alerts.
- **The output shape stays the same.** Sentry serializes the created
Monitor as `dataSources[0].queryObj`, so the tool returns the same
summary with no second request. The only addition is the connected
`workflowIds`. The owner is sent on both the detector and the monitor,
which matches what the legacy path copied over.
- **Agents are told about seat-disabled monitors.** When the org has no
monitor seat available, Sentry still returns success but disables the
monitor. The description now tells the agent to report an unrequested
`disabled` status to the user.

I checked the request and response shapes against
getsentry/sentry@e39c07b (`MonitorIncidentDetectorValidator`,
`MonitorDataSourceValidator`, and the base detector `create`). Nothing
has been run against a live org yet.

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC08J1NSPU6S%3A1793724602.686199 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC08J1NSPU6S%3A1793724602.686199)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC08J1NSPU6S%3A1793724602.686199/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active and 1 inactive deployments
Actions — 431f6a71 Deployed Nov 3, 2026 by sentry-junior[bot] via eval #1505
Preview — 431f6a71 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant