Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/cli-docs/src/content/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ cli/
│ │ ├── snapshots/ # diff, download, upload
│ │ ├── sourcemap/ # inject, resolve, upload
│ │ ├── span/ # list, view
│ │ ├── status/ # show
│ │ ├── team/ # list
│ │ ├── trace/ # list, logs, view
│ │ ├── trial/ # list, start
Expand Down
29 changes: 29 additions & 0 deletions apps/cli-docs/src/fragments/commands/status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


## Examples

```bash
# Show the current status of Sentry's services
sentry status
```

```
✓ All Systems Operational

### Components

● Dashboard — Operational
● US Error Ingestion — Operational

See https://status.sentry.io for full details.
```

```bash
# Get machine-readable status (useful in scripts)
sentry status --json
```

```bash
# Check a self-hosted or regional status page (Statuspage CNAME)
sentry status --url https://status.acme.com
```
8 changes: 8 additions & 0 deletions packages/cli/plugins/sentry-cli/skills/sentry-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,14 @@ List and view spans in projects or traces

→ Full flags and examples: `references/span.md`

### Status

Check Sentry service status

- `sentry status show` — Show Sentry service status

→ Full flags and examples: `references/status.md`

### Trace

View distributed traces
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: sentry-cli-status
version: 0.44.0-dev.0
description: Check Sentry service status
requires:
bins: ["sentry"]
auth: true
---

# Status Commands

Check Sentry service status

### `sentry status show`

Show Sentry service status

**Flags:**
- `--url <value> - Status page base URL to query - (default: "https://status.sentry.io")`

**Examples:**

```bash
# Show the current status of Sentry's services
sentry status

# Get machine-readable status (useful in scripts)
sentry status --json

# Check a self-hosted or regional status page (Statuspage CNAME)
sentry status --url https://status.acme.com
```

All commands also support `--json`, `--fields`, `--help`, `--log-level`, and `--verbose` flags.
2 changes: 2 additions & 0 deletions packages/cli/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { snapshotsRoute } from "./commands/snapshots/index.js";
import { sourcemapRoute } from "./commands/sourcemap/index.js";
import { spanRoute } from "./commands/span/index.js";
import { listCommand as spanListCommand } from "./commands/span/list.js";
import { statusRoute } from "./commands/status/index.js";
import { teamRoute } from "./commands/team/index.js";
import { listCommand as teamListCommand } from "./commands/team/list.js";
import { traceRoute } from "./commands/trace/index.js";
Expand Down Expand Up @@ -140,6 +141,7 @@ export const routes = buildRouteMap({
sourcemap: sourcemapRoute,
sourcemaps: sourcemapRoute,
span: spanRoute,
status: statusRoute,
trace: traceRoute,
trial: trialRoute,
init: initCommand,
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/src/commands/status/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* sentry status
*
* Check the status of Sentry's services.
*/

import { buildRouteMap } from "../../lib/route-map.js";
import { showCommand } from "./show.js";

export const statusRoute = buildRouteMap({
routes: {
show: showCommand,
},
defaultCommand: "show",
docs: {
brief: "Check Sentry service status",
fullDescription:
"Report the current status of Sentry's services using the public " +
"status page (https://status.sentry.io) as the backend.\n\n" +
"Running `sentry status` with no subcommand shows the current status.",
hideRoute: {},
},
});
57 changes: 57 additions & 0 deletions packages/cli/src/commands/status/show.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* sentry status show
*
* Report the current status of Sentry's services by querying the public
* Statuspage backend at https://status.sentry.io. Useful when the Sentry API
* is degraded and you want to know whether the problem is on Sentry's side.
*/

import type { SentryContext } from "../../context.js";
import {
fetchSentryStatus,
SENTRY_STATUS_PAGE_URL,
} from "../../lib/api/status-page.js";
import { buildCommand } from "../../lib/command.js";
import { formatSentryStatus } from "../../lib/formatters/human.js";
import { CommandOutput } from "../../lib/formatters/output.js";

type ShowFlags = {
readonly json: boolean;
readonly url: string;
readonly fields?: string[];
};

export const showCommand = buildCommand({
// Checking the public status page requires no Sentry credentials.
auth: false,
docs: {
brief: "Show Sentry service status",
fullDescription:
"Report the current status of Sentry's services using the public " +
"status page (https://status.sentry.io) as the backend.\n\n" +
"This works even when the Sentry API is degraded or unreachable, so " +
"you can tell whether an issue is on Sentry's side. Point `--url` at a " +
"different Statuspage instance to check a self-hosted or regional page.",
},
output: { human: formatSentryStatus },
parameters: {
flags: {
url: {
kind: "parsed",
parse: String,
brief: "Status page base URL to query",
default: SENTRY_STATUS_PAGE_URL,
},
},
},
async *func(this: SentryContext, flags: ShowFlags) {
const status = await fetchSentryStatus(flags.url);
yield new CommandOutput(status);

if (status.indicator !== "none") {
return {
hint: `Run \`sentry status\` again to refresh, or open ${status.url}`,
};
}
},
});
197 changes: 197 additions & 0 deletions packages/cli/src/lib/api/status-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/**
* Statuspage.io API client for Sentry's public status page.
*
* Sentry's status page (https://status.sentry.io) is hosted on Statuspage.io,
* which exposes a stable JSON summary at `/api/v2/summary.json`. This module
* fetches and shapes that payload for the `sentry status` command.
*
* The request is bounded by an explicit timeout so a status check never hangs,
* which is the whole point of the command — it is meant to work even while the
* Sentry API itself is degraded.
*/

import { customFetch } from "../custom-ca.js";
import { ApiError } from "../errors.js";

/** Default Sentry status page base URL. */
export const SENTRY_STATUS_PAGE_URL = "https://status.sentry.io";

/** Bound the request so a status check never hangs, even during an outage. */
const STATUS_REQUEST_TIMEOUT_MS = 10_000;

/** Shorter timeout for the lightweight /_health/ probe (self-hosted or sentry.io). */
const HEALTH_REQUEST_TIMEOUT_MS = 5000;

/** Matches one or more trailing slashes so base URLs normalize cleanly. */
const TRAILING_SLASHES = /\/+$/;

/** Overall indicator reported by Statuspage. */
export type StatusIndicator =
| "none"
| "minor"
| "major"
| "critical"
| "maintenance";

/** Per-component operational status reported by Statuspage. */
export type ComponentStatus =
| "operational"
| "degraded_performance"
| "partial_outage"
| "major_outage"
| "under_maintenance";

/** A single service component on the status page. */
export type StatusComponent = {
readonly name: string;
readonly status: ComponentStatus;
};

/** An ongoing or recent incident. */
export type StatusIncident = {
readonly name: string;
readonly status: string;
readonly impact: string;
readonly shortlink: string;
};

/** Structured status data: JSON output shape and human-formatter input. */
export type SentryStatus = {
/** Overall indicator and human-readable description. */
readonly indicator: StatusIndicator;
readonly description: string;
/** Status page URL the data was fetched from. */
readonly url: string;
/** All service components with their current status. */
readonly components: readonly StatusComponent[];
/** Unresolved incidents currently shown on the status page. */
readonly incidents: readonly StatusIncident[];
};

/** Shape of the Statuspage `/api/v2/summary.json` response we consume. */
type SummaryResponse = {
page?: { url?: string };
status?: { indicator?: string; description?: string };
components?: Array<{ name?: string; status?: string; group?: boolean }>;
incidents?: Array<{
name?: string;
status?: string;
impact?: string;
shortlink?: string;
}>;
};

/**
* Fetch the current Sentry service status from a Statuspage summary endpoint.
*
* @param baseUrl - Status page base URL (defaults to status.sentry.io). Pass a
* custom URL to point at a self-hosted or regional Statuspage instance.
*/
export function fetchSentryStatus(
baseUrl: string = SENTRY_STATUS_PAGE_URL
): Promise<SentryStatus> {
const normalized = baseUrl.replace(TRAILING_SLASHES, "");

// Statuspage hosts (statuspage.io) use the /api/v2/summary.json flow.
// All other hosts (self-hosted) are probed via the generic /_health/ endpoint.
let parsedUrl: URL | undefined;
try {
parsedUrl = new URL(normalized);
} catch {
parsedUrl = undefined;
}
const host = parsedUrl?.hostname.toLowerCase() ?? "";
// Sentry's public status page (status.sentry.io) is a Statuspage instance,
// as are any *.statuspage.io hosts and common CNAMEs containing "status"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not better to do a DNS look up or direct API call test rather than a set of known URLs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heuristic (any host containing "status") is intentionally loose to support common Statuspage CNAMEs (status.acme.com, statuspage.example.com, …) while still excluding obvious non-Statuspage hosts. The crash-safety net already exists: any non-ApiError from a misclassified host falls back to the synthetic health status. Explicit ApiErrors still propagate so CLI error handling is unchanged.

Items 1 (per-endpoint timeouts) and 3 (auto status check + 5xx suppression) are acknowledged as follow-up work. They are cross-cutting changes that would make this PR much larger and shift its focus away from the bounded deliverable (the sentry status command group). Happy to open separate issues/PRs for them if you'd like them tracked.

// (status.example.com, statuspage.acme.com, …). Everything else falls back
// to the lightweight self-hosted /_health/ probe.
const isStatuspageHost =
host === "status.sentry.io" ||
host.endsWith(".statuspage.io") ||
host.includes("status");
Comment thread
sentry[bot] marked this conversation as resolved.

return isStatuspageHost
? fetchStatuspageSummary(normalized)
: probeSelfHostedHealth(normalized);
}

/** Fetch and shape a Statuspage `/api/v2/summary.json` response. */
async function fetchStatuspageSummary(
normalized: string
): Promise<SentryStatus> {
const endpoint = `${normalized}/api/v2/summary.json`;

const response = await customFetch(endpoint, {
signal: AbortSignal.timeout(STATUS_REQUEST_TIMEOUT_MS),
});

if (!response.ok) {
throw new ApiError(
"Failed to fetch Sentry status",
response.status,
await response.text(),
endpoint
);
}

const summary = (await response.json()) as SummaryResponse;

const components: StatusComponent[] = (summary.components ?? [])
// Group headers carry no operational status of their own.
.filter((c) => !c.group && typeof c.name === "string")
.map((c) => ({
name: c.name as string,
status: (c.status as ComponentStatus) ?? "operational",
}));

const incidents: StatusIncident[] = (summary.incidents ?? []).map((i) => ({
name: i.name ?? "Unnamed incident",
status: i.status ?? "unknown",
impact: i.impact ?? "none",
shortlink: i.shortlink ?? normalized,
}));

return {
indicator: (summary.status?.indicator as StatusIndicator) ?? "none",
description: summary.status?.description ?? "Unknown",
url: summary.page?.url ?? normalized,
components,
incidents,
};
}

/**
* Probe a self-hosted Sentry's `/_health/` endpoint. Never throws — network or
* HTTP failures are reported as a synthetic "major" status so the command can
* still render something useful when the instance is down.
*
* Uses `?full=1` so the check exercises every subsystem (Postgres, Redis,
* Celery, …) rather than the bare liveness probe: without it Sentry returns
* HTTP 200 whenever the web process is up, masking real backend outages.
*/
async function probeSelfHostedHealth(
normalized: string
): Promise<SentryStatus> {
const healthEndpoint = `${normalized}/_health/?full=1`;
try {
const resp = await customFetch(healthEndpoint, {
signal: AbortSignal.timeout(HEALTH_REQUEST_TIMEOUT_MS),
});

return {
indicator: resp.ok ? "none" : "major",
description: resp.statusText || (resp.ok ? "OK" : `HTTP ${resp.status}`),
url: normalized,
components: [],
incidents: [],
};
Comment thread
jared-outpost[bot] marked this conversation as resolved.
} catch (err) {
return {
indicator: "major",
description: err instanceof Error ? err.message : String(err),
url: normalized,
components: [],
incidents: [],
};
}
}
Loading
Loading