chore: fix model alerts (#25990)

This commit is contained in:
Victor Navarro
2026-05-06 16:57:34 +02:00
committed by GitHub
parent 2abc4507b2
commit 889f979c0b
2 changed files with 12 additions and 12 deletions
+8 -10
View File
@@ -178,7 +178,7 @@ new incident.AlertRoute("HoneycombAlertRoute", {
reference: $interpolate`alert.attributes.${fields.product.id}`, reference: $interpolate`alert.attributes.${fields.product.id}`,
}, },
], ],
groupingWindowSeconds: 900, groupingWindowSeconds: 3600,
}, },
incidentTemplate: { incidentTemplate: {
name: { name: {
@@ -215,7 +215,6 @@ type Trigger = (opts: { model: string; product: Product }) => {
description: string description: string
json: honeycomb.GetQuerySpecificationOutputArgs json: honeycomb.GetQuerySpecificationOutputArgs
threshold: { op: ">=" | "<="; value: number } threshold: { op: ">=" | "<="; value: number }
baseline: 3600 | 86400
} }
type Model = { id: string; products: Product[]; triggers: Trigger[] } type Model = { id: string; products: Product[]; triggers: Trigger[] }
@@ -232,6 +231,8 @@ const httpErrors: Trigger = ({ model, product }) => ({
filterCombination: "AND", filterCombination: "AND",
filters: [ filters: [
{ column: "model", op: "=", value: model }, { column: "model", op: "=", value: model },
{ column: "event_type", op: "=", value: "completions" },
{ column: "user_agent", op: "contains", value: "opencode" },
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" }, { column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
], ],
}, },
@@ -241,6 +242,8 @@ const httpErrors: Trigger = ({ model, product }) => ({
filterCombination: "AND", filterCombination: "AND",
filters: [ filters: [
{ column: "model", op: "=", value: model }, { column: "model", op: "=", value: model },
{ column: "event_type", op: "=", value: "completions" },
{ column: "user_agent", op: "contains", value: "opencode" },
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" }, { column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
{ column: "status", op: ">=", value: "400" }, { column: "status", op: ">=", value: "400" },
{ column: "status", op: "!=", value: "401" }, { column: "status", op: "!=", value: "401" },
@@ -250,10 +253,7 @@ const httpErrors: Trigger = ({ model, product }) => ({
formulas: [{ name: "ERROR", expression: "$FAILED / $TOTAL" }], formulas: [{ name: "ERROR", expression: "$FAILED / $TOTAL" }],
timeRange: 900, timeRange: 900,
}, },
// Alert when errors surge 50% compared to the previous period threshold: { op: ">=", value: 0.8 },
threshold: { op: ">=", value: 50 },
// What previous time period to evaluate against
baseline: 3600,
}) })
const models: Model[] = [ const models: Model[] = [
@@ -296,10 +296,8 @@ for (const model of models) {
name: spec.title, name: spec.title,
description: spec.description, description: spec.description,
queryJson: honeycomb.getQuerySpecificationOutput(spec.json).json, queryJson: honeycomb.getQuerySpecificationOutput(spec.json).json,
alertType: "on_change", alertType: "on_true",
// This is the minimum when using % change detection frequency: 300,
frequency: 900,
baselineDetails: [{ type: "percentage", offsetMinutes: spec.baseline / 60 }],
thresholds: [{ ...spec.threshold, exceededLimit: 1 }], thresholds: [{ ...spec.threshold, exceededLimit: 1 }],
recipients: [ recipients: [
{ {
@@ -2,6 +2,8 @@ import type { APIEvent } from "@solidjs/start/server"
import { Resource } from "@opencode-ai/console-resource" import { Resource } from "@opencode-ai/console-resource"
import { Webhook } from "svix" import { Webhook } from "svix"
const DISCORD_INCIDENT_ROLE_ID = "1501447160175136838"
type Incident = { type Incident = {
mode?: "test" | "standard" mode?: "test" | "standard"
name?: string name?: string
@@ -37,14 +39,14 @@ const postDiscordMessage = async (incident: Incident) => {
`**${incident.mode === "test" ? "[TEST] " : ""}${incident.name ?? "Incident has been created"}**`, `**${incident.mode === "test" ? "[TEST] " : ""}${incident.name ?? "Incident has been created"}**`,
incident.summary, incident.summary,
"", "",
"@inference", `<@&${DISCORD_INCIDENT_ROLE_ID}>`,
"", "",
incident.permalink, incident.permalink,
] ]
.filter((line) => line !== undefined) .filter((line) => line !== undefined)
.join("\n"), .join("\n"),
allowed_mentions: { allowed_mentions: {
parse: ["everyone"], roles: [DISCORD_INCIDENT_ROLE_ID],
}, },
flags: 4, flags: 4,
}), }),