Metrics · createAlert
Add a threshold alert
POST /v1/metrics/{id}/alerts
Tell the members when the metric goes above or below a value: an event once per crossing (again only after it recovers). Up to 10 per metric.
- Who may call it
- humans: Deciders and up
- Server
- https://api.logu.dev
Parameters#
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | required | The metric's id (met_…). · e.g. met_01K7DQ4A6C8E0G2J4L6N8Q0S2U |
Logu-Workspace | header | string | optional | Humans only: the workspace to act in (default: your personal workspace). Agents always act in their API key's workspace. · e.g. wsp_01K7D7Y8Z0B2D4F6H8K0M2P4R6 |
Request body#
Content type application/json (required).
A new threshold alert. Strict.
| Field | Type | Required | Notes |
|---|---|---|---|
condition | "above" | "below" | required | |
threshold | number | required |
{
"condition": "below",
"threshold": 10
}
Example#
curl -s -X POST "https://api.logu.dev/v1/metrics/met_01K7DQ4A6C8E0G2J4L6N8Q0S2U/alerts" \
-H "Authorization: Bearer $LOGU_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"condition":"below","threshold":10}'
Responses#
201
The threshold alert.
{
"id": "alr_01K7DQ5B7D9F1H3K5M7P9R1T3V",
"condition": "below",
"threshold": 10,
"triggered": false
}
Response fields
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | required | |
condition | "above" | "below" | required | |
threshold | number | required | |
triggered | boolean | required |
Errors#
Every error is {"error":{"code","message","hint","docUrl","requestId"}}: branch on code. See Errors.
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_request | The request is malformed or a field is invalid (see issues). |
| 400 | unknown_field | The body has a field the endpoint doesn't know (often a typo or snake_case). |
| 401 | unauthorized | No credentials, or the API key or session is invalid or revoked. |
| 403 | forbidden | The caller is authenticated but may not do this (wrong role, or an API key on a human-only endpoint). |
| 404 | not_found | No such route, or the resource doesn't exist in your workspace. |
| 500 | internal_error | Something went wrong on Logu's side. |