Alerts
List Alerts
Returns the alerts visible to the caller, newest first. Usestarting_after or ending_before to page.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.list()
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.list();
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
"project_id": Optional[str],
}
{
limit?: number;
startingAfter?: string;
endingBefore?: string;
projectId?: string;
}
Show Response
Show Response
{
"object": str,
"data": [{
"alert_id": str,
"display_name": str,
"description": str,
"project_id": str,
"signal": Literal["cost", "latency", "errors", "evals", "custom"],
"query": {
"metric": str,
"filters": [{ # optional
"field": str,
"op": Literal["eq", "neq", "in", "not_in"],
"values": List[str],
}],
},
"condition": {
"comparator": Literal["gt", "gte", "lt", "lte", "eq"],
"threshold": float,
"degraded_threshold": Optional[float],
"resolve_threshold": Optional[float],
"window": Literal["5m", "15m", "30m", "1h", "4h", "1d"],
"interval": Literal["30s", "5m", "15m", "1h", "1d"],
"delay": Optional[Literal["30s", "60s", "120s", "300s", "600s"]],
},
"notifier_ids": List[str],
"enabled": bool,
"status": Literal["ok", "degraded", "triggered"],
"last_triggered_at": date, # optional
"recent_runs": [{ # optional
"at": date,
"value": float,
"breached": bool,
"has_data": bool,
"severity": Optional[Literal["critical", "degraded"]],
}],
"created_at": date,
"updated_at": date,
"created_by_id": str,
"updated_by_id": str,
}],
"has_more": bool,
}
{
object: string;
data: {
alertId: string;
displayName: string;
description: string;
projectId: string;
signal: "cost" | "latency" | "errors" | "evals" | "custom";
query: {
metric: string;
filters?: {
field: string;
op: "eq" | "neq" | "in" | "not_in";
values: string[];
}[];
};
condition: {
comparator: "gt" | "gte" | "lt" | "lte" | "eq";
threshold: number;
degradedThreshold?: number;
resolveThreshold?: number;
window: "5m" | "15m" | "30m" | "1h" | "4h" | "1d";
interval: "30s" | "5m" | "15m" | "1h" | "1d";
delay?: "30s" | "60s" | "120s" | "300s" | "600s";
};
notifierIds: string[];
enabled: boolean;
status: "ok" | "degraded" | "triggered";
lastTriggeredAt?: Date;
recentRuns?: {
at: Date;
value: number;
breached: boolean;
hasData: boolean;
severity?: "critical" | "degraded";
}[];
createdAt: Date;
updatedAt: Date;
createdById: string;
updatedById: string;
}[];
hasMore: boolean;
}
Create an Alert
Creates a threshold alert in a project. The alert’s query is validated against the Reporting API metric catalogue and the evaluation schedule starts immediately whenenabled is true. Plan limits apply to the number of alerts and the minimum evaluation interval.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.create(display_name="Freeman80", project_id="<id>", query={
"metric": "<value>",
}, condition={
"comparator": "gte",
"threshold": 7213.05,
"window": "30m",
"interval": "5m",
})
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.create({
displayName: "Freeman80",
projectId: "<id>",
query: {
metric: "<value>",
},
condition: {
comparator: "gte",
threshold: 7213.05,
window: "30m",
interval: "5m",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"display_name": str, # required
"project_id": str, # required
"query": { # required
"metric": str, # required
"filters": [{ # optional
"field": str, # required
"op": Literal["eq", "neq", "in", "not_in"], # required
"values": List[str], # required
}],
},
"condition": { # required
"comparator": Literal["gt", "gte", "lt", "lte", "eq"], # required
"threshold": float, # required
"degraded_threshold": Optional[float],
"resolve_threshold": Optional[float],
"window": Literal["5m", "15m", "30m", "1h", "4h", "1d"], # required
"interval": Literal["30s", "5m", "15m", "1h", "1d"], # required
"delay": Optional[Literal["30s", "60s", "120s", "300s", "600s"]],
},
"description": Optional[str],
"signal": Optional[str],
"notifier_ids": List[str], # optional
"enabled": Optional[bool],
}
{
displayName: string; // required
description?: string;
projectId: string; // required
signal?: string;
query: { // required
metric: string; // required
filters?: {
field: string; // required
op: "eq" | "neq" | "in" | "not_in"; // required
values: string[]; // required
}[];
};
condition: { // required
comparator: "gt" | "gte" | "lt" | "lte" | "eq"; // required
threshold: number; // required
degradedThreshold?: number;
resolveThreshold?: number;
window: "5m" | "15m" | "30m" | "1h" | "4h" | "1d"; // required
interval: "30s" | "5m" | "15m" | "1h" | "1d"; // required
delay?: "30s" | "60s" | "120s" | "300s" | "600s";
};
notifierIds?: string[];
enabled?: boolean;
}
Show Response
Show Response
{
"alert": {
"alert_id": str,
"display_name": str,
"description": str,
"project_id": str,
"signal": Literal["cost", "latency", "errors", "evals", "custom"],
"query": {
"metric": str,
"filters": [{ # optional
"field": str,
"op": Literal["eq", "neq", "in", "not_in"],
"values": List[str],
}],
},
"condition": {
"comparator": Literal["gt", "gte", "lt", "lte", "eq"],
"threshold": float,
"degraded_threshold": Optional[float],
"resolve_threshold": Optional[float],
"window": Literal["5m", "15m", "30m", "1h", "4h", "1d"],
"interval": Literal["30s", "5m", "15m", "1h", "1d"],
"delay": Optional[Literal["30s", "60s", "120s", "300s", "600s"]],
},
"notifier_ids": List[str],
"enabled": bool,
"status": Literal["ok", "degraded", "triggered"],
"last_triggered_at": date, # optional
"recent_runs": [{ # optional
"at": date,
"value": float,
"breached": bool,
"has_data": bool,
"severity": Optional[Literal["critical", "degraded"]],
}],
"created_at": date,
"updated_at": date,
"created_by_id": str,
"updated_by_id": str,
},
}
{
alert: {
alertId: string;
displayName: string;
description: string;
projectId: string;
signal: "cost" | "latency" | "errors" | "evals" | "custom";
query: {
metric: string;
filters?: {
field: string;
op: "eq" | "neq" | "in" | "not_in";
values: string[];
}[];
};
condition: {
comparator: "gt" | "gte" | "lt" | "lte" | "eq";
threshold: number;
degradedThreshold?: number;
resolveThreshold?: number;
window: "5m" | "15m" | "30m" | "1h" | "4h" | "1d";
interval: "30s" | "5m" | "15m" | "1h" | "1d";
delay?: "30s" | "60s" | "120s" | "300s" | "600s";
};
notifierIds: string[];
enabled: boolean;
status: "ok" | "degraded" | "triggered";
lastTriggeredAt?: Date;
recentRuns?: {
at: Date;
value: number;
breached: boolean;
hasData: boolean;
severity?: "critical" | "degraded";
}[];
createdAt: Date;
updatedAt: Date;
createdById: string;
updatedById: string;
};
}
Retrieve an Alert
Retrieves an alert by ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.get(alert_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.get({
alertId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"alert_id": str, # required
}
{
alertId: string; // required
}
Show Response
Show Response
{
"alert": {
"alert_id": str,
"display_name": str,
"description": str,
"project_id": str,
"signal": Literal["cost", "latency", "errors", "evals", "custom"],
"query": {
"metric": str,
"filters": [{ # optional
"field": str,
"op": Literal["eq", "neq", "in", "not_in"],
"values": List[str],
}],
},
"condition": {
"comparator": Literal["gt", "gte", "lt", "lte", "eq"],
"threshold": float,
"degraded_threshold": Optional[float],
"resolve_threshold": Optional[float],
"window": Literal["5m", "15m", "30m", "1h", "4h", "1d"],
"interval": Literal["30s", "5m", "15m", "1h", "1d"],
"delay": Optional[Literal["30s", "60s", "120s", "300s", "600s"]],
},
"notifier_ids": List[str],
"enabled": bool,
"status": Literal["ok", "degraded", "triggered"],
"last_triggered_at": date, # optional
"recent_runs": [{ # optional
"at": date,
"value": float,
"breached": bool,
"has_data": bool,
"severity": Optional[Literal["critical", "degraded"]],
}],
"created_at": date,
"updated_at": date,
"created_by_id": str,
"updated_by_id": str,
},
}
{
alert: {
alertId: string;
displayName: string;
description: string;
projectId: string;
signal: "cost" | "latency" | "errors" | "evals" | "custom";
query: {
metric: string;
filters?: {
field: string;
op: "eq" | "neq" | "in" | "not_in";
values: string[];
}[];
};
condition: {
comparator: "gt" | "gte" | "lt" | "lte" | "eq";
threshold: number;
degradedThreshold?: number;
resolveThreshold?: number;
window: "5m" | "15m" | "30m" | "1h" | "4h" | "1d";
interval: "30s" | "5m" | "15m" | "1h" | "1d";
delay?: "30s" | "60s" | "120s" | "300s" | "600s";
};
notifierIds: string[];
enabled: boolean;
status: "ok" | "degraded" | "triggered";
lastTriggeredAt?: Date;
recentRuns?: {
at: Date;
value: number;
breached: boolean;
hasData: boolean;
severity?: "critical" | "degraded";
}[];
createdAt: Date;
updatedAt: Date;
createdById: string;
updatedById: string;
};
}
Delete an Alert
Permanently deletes an alert together with its trigger history and events, and stops the evaluation schedule.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.delete(alert_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.delete({
alertId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"alert_id": str, # required
}
{
alertId: string; // required
}
Update an Alert
Updates alert metadata, query, condition, notifiers, or enabled state. Query and condition changes restart the evaluation schedule; disabling stops it.project_id is immutable.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.update(alert_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.update({
alertId: "<id>",
updateAlertRequest: {},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"alert_id": str, # required
"display_name": Optional[str],
"description": Optional[str],
"signal": Optional[str],
"query": { # optional
"metric": str, # required
"filters": [{ # optional
"field": str, # required
"op": Literal["eq", "neq", "in", "not_in"], # required
"values": List[str], # required
}],
},
"condition": { # optional
"comparator": Literal["gt", "gte", "lt", "lte", "eq"], # required
"threshold": float, # required
"degraded_threshold": Optional[float],
"resolve_threshold": Optional[float],
"window": Literal["5m", "15m", "30m", "1h", "4h", "1d"], # required
"interval": Literal["30s", "5m", "15m", "1h", "1d"], # required
"delay": Optional[Literal["30s", "60s", "120s", "300s", "600s"]],
},
"notifier_ids": List[str], # optional
"enabled": Optional[bool],
}
{
alertId: string; // required
updateAlertRequest: { // required
displayName?: string;
description?: string;
signal?: string;
query?: {
metric: string; // required
filters?: {
field: string; // required
op: "eq" | "neq" | "in" | "not_in"; // required
values: string[]; // required
}[];
};
condition?: {
comparator: "gt" | "gte" | "lt" | "lte" | "eq"; // required
threshold: number; // required
degradedThreshold?: number;
resolveThreshold?: number;
window: "5m" | "15m" | "30m" | "1h" | "4h" | "1d"; // required
interval: "30s" | "5m" | "15m" | "1h" | "1d"; // required
delay?: "30s" | "60s" | "120s" | "300s" | "600s";
};
notifierIds?: string[];
enabled?: boolean;
};
}
Show Response
Show Response
{
"alert": {
"alert_id": str,
"display_name": str,
"description": str,
"project_id": str,
"signal": Literal["cost", "latency", "errors", "evals", "custom"],
"query": {
"metric": str,
"filters": [{ # optional
"field": str,
"op": Literal["eq", "neq", "in", "not_in"],
"values": List[str],
}],
},
"condition": {
"comparator": Literal["gt", "gte", "lt", "lte", "eq"],
"threshold": float,
"degraded_threshold": Optional[float],
"resolve_threshold": Optional[float],
"window": Literal["5m", "15m", "30m", "1h", "4h", "1d"],
"interval": Literal["30s", "5m", "15m", "1h", "1d"],
"delay": Optional[Literal["30s", "60s", "120s", "300s", "600s"]],
},
"notifier_ids": List[str],
"enabled": bool,
"status": Literal["ok", "degraded", "triggered"],
"last_triggered_at": date, # optional
"recent_runs": [{ # optional
"at": date,
"value": float,
"breached": bool,
"has_data": bool,
"severity": Optional[Literal["critical", "degraded"]],
}],
"created_at": date,
"updated_at": date,
"created_by_id": str,
"updated_by_id": str,
},
}
{
alert: {
alertId: string;
displayName: string;
description: string;
projectId: string;
signal: "cost" | "latency" | "errors" | "evals" | "custom";
query: {
metric: string;
filters?: {
field: string;
op: "eq" | "neq" | "in" | "not_in";
values: string[];
}[];
};
condition: {
comparator: "gt" | "gte" | "lt" | "lte" | "eq";
threshold: number;
degradedThreshold?: number;
resolveThreshold?: number;
window: "5m" | "15m" | "30m" | "1h" | "4h" | "1d";
interval: "30s" | "5m" | "15m" | "1h" | "1d";
delay?: "30s" | "60s" | "120s" | "300s" | "600s";
};
notifierIds: string[];
enabled: boolean;
status: "ok" | "degraded" | "triggered";
lastTriggeredAt?: Date;
recentRuns?: {
at: Date;
value: number;
breached: boolean;
hasData: boolean;
severity?: "critical" | "degraded";
}[];
createdAt: Date;
updatedAt: Date;
createdById: string;
updatedById: string;
};
}
List Triggers
Returns the trigger history of an alert, newest first. A trigger is one breach incident: it opens when the threshold is first crossed and resolves when the value recovers.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.list_triggers(alert_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.listTriggers({
alertId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"alert_id": str, # required
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
}
{
alertId: string; // required
limit?: number;
startingAfter?: string;
endingBefore?: string;
}
Show Response
Show Response
{
"object": str,
"data": [{
"trigger_id": str,
"alert_id": str,
"project_id": str,
"status": Literal["open", "resolved"],
"severity": Optional[Literal["critical", "degraded"]],
"peak_severity": Optional[Literal["critical", "degraded"]],
"opened_at": date,
"resolved_at": date, # optional
"peak_value": float,
"last_value": float,
"event_count": int,
}],
"has_more": bool,
}
{
object: string;
data: {
triggerId: string;
alertId: string;
projectId: string;
status: "open" | "resolved";
severity?: "critical" | "degraded";
peakSeverity?: "critical" | "degraded";
openedAt: Date;
resolvedAt?: Date;
peakValue: number;
lastValue: number;
eventCount: number;
}[];
hasMore: boolean;
}
List Trigger Events
Returns the evaluation events recorded while a trigger was open, newest first. Each event carries the observed value and, when available, exemplar traces that contributed to the breach.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.alerts.list_trigger_events(alert_id="<id>", trigger_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.alerts.listTriggerEvents({
alertId: "<id>",
triggerId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"alert_id": str, # required
"trigger_id": str, # required
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
}
{
alertId: string; // required
triggerId: string; // required
limit?: number;
startingAfter?: string;
endingBefore?: string;
}
Show Response
Show Response
{
"object": str,
"data": [{
"event_id": str,
"trigger_id": str,
"alert_id": str,
"at": date,
"value": float,
"evidence": [{ # optional
"trace_id": str,
"span_id": str,
"start_time": date,
"value": float,
}],
}],
"has_more": bool,
}
{
object: string;
data: {
eventId: string;
triggerId: string;
alertId: string;
at: Date;
value: number;
evidence?: {
traceId: string;
spanId: string;
startTime: Date;
value: number;
}[];
}[];
hasMore: boolean;
}