Skip to content

Expose metric monitor aggregates in the OpenAPI schema #129450

Closed

Description

@sentry-junior

The public API schema does not say which aggregate values a metric monitor (detector) data source accepts. Clients such as @sentry/api and the Sentry CLI copy the list from the backend source instead, and their copies drift from it.

  • BaseDetectorTypeValidator.data_sources (src/sentry/workflow_engine/endpoints/validators/base/detector.py) is a plain ListField. The generated schema therefore types it as Array<unknown>. This is still the case in @sentry/api 0.432.0.
  • The only aggregates the schema mentions are prose examples in DATA_SOURCES_HELP_TEXT (workflow_engine/endpoints/validators/api_docs_help_text.py), and some are out of date. For example, it lists percentile(measurements.lcp,x), but EAP spans don't define percentile (src/sentry/search/eap/spans/aggregates.py).
  • The accepted aggregates are scattered across the code:
    • SnubaQueryValidator._validate_aggregate (src/sentry/snuba/snuba_query_validator.py).
    • EAP spans/logs: EAP_FUNCTIONS, plus the definitions of each dataset (search/eap/spans, search/eap/ourlogs, which has no formulas).
    • Errors: SUPPORTED_COLUMNS / TRANSLATABLE_COLUMNS (src/sentry/incidents/logic.py).
    • Crash rate: CRASH_RATE_ALERT_AGGREGATE_RE (src/sentry/snuba/entity_subscription.py).
  • The public schema is generated here (.github/workflows/openapi.yml runs make build-api-docs and copies tests/apidocs/openapi-derefed.json into getsentry/sentry-api-schema), so the change has to be made in this repo.

Impact: a client that validates or completes aggregates has to copy these rules by hand. getsentry/toolkit#1785 does this for CLI shell completion.

via @BYK.

--

View Session in Sentry

Activity

  1. linear-code commented on Nov 1, 2026

    @linear-code
  2. added a commit that references this issue on Nov 3, 2026
    45c0d00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions