SRE → investigate alert
Start an SRE Copilot investigation from an alert that already exists in the SRE app, then poll until the investigation record has RCA fields. Requires the SRE app installed on the project and an API token.
| Step | What the SDK does |
|---|---|
| 1. List or get alert | GET /app/sre/api/v1/alerts or GET /app/sre/api/v1/alerts/{id} |
| 2. Investigate | POST /app/sre/api/v1/alerts/{id}/investigate (returns immediately) |
| 3. Poll | GET /app/sre/api/v1/investigations/{id} until status is terminal |
| 4. Optional | Use guild_session_id with Aiden artifact/export APIs for the session file |
Prefer this path when the alert is already in Copilot and you want the investigation record plus structured RCA. Use Ask → artifact when you only have a free-text prompt and no SRE alert id.
Minimal — list, investigate, poll
import time
from stackgen import StackgenClient, StackgenConfig
client = StackgenClient(
StackgenConfig(
base_url="https://app.stackgen.com",
api_token="stackgen_…",
org_id="<project-uuid>",
)
)
alerts = client.sre.list_alerts(status="active", q="checkout CPU")
items = alerts.get("items") or []
alert_id = items[0]["id"]
started = client.sre.investigate_alert(
alert_id,
body={"operator_message": "Investigate checkout CPU in prod"},
)
inv_id = started["investigation"]["id"]
while True:
inv = client.sre.get_investigation(inv_id)
status = inv.get("status")
if status in ("completed", "failed", "cancelled", "error"):
break
time.sleep(5)
print(inv.get("result_summary"))
print(inv.get("guild_session_id"))import { StackgenClient, StackgenConfig } from "stackgen-sdk";
const client = new StackgenClient(
new StackgenConfig({
baseUrl: "https://app.stackgen.com",
apiToken: "stackgen_…",
orgId: "<project-uuid>",
}),
);
const alerts = (await client.sre.listAlerts({
status: "active",
q: "checkout CPU",
})) as { items?: Array<{ id: string }> };
const alertId = alerts.items?.[0]?.id;
if (!alertId) {
throw new Error("no matching alert");
}
const started = (await client.sre.investigateAlert(alertId, {
operator_message: "Investigate checkout CPU in prod",
})) as { investigation: { id: string } };
const invId = started.investigation.id;
let inv: Record<string, unknown> = {};
for (;;) {
inv = (await client.sre.getInvestigation(invId)) as Record<string, unknown>;
const status = String(inv.status ?? "");
if (["completed", "failed", "cancelled", "error"].includes(status)) {
break;
}
await new Promise((r) => setTimeout(r, 5000));
}
console.log(inv.result_summary);
console.log(inv.guild_session_id);Notes
investigate_alertdoes not block for full RCA. Pollget_investigation.- If the alert id is unknown, the API returns 404. Sync or ingest alerts into the SRE app first.
- Optional body fields:
force_new,operator_message,remediation_requested. - When
guild_session_idis set, downloadsession-report.mdor callclient.aiden.export_session(session_id, parts="report").
Related: Automation surface · Ask → artifact