curl --request POST \
--url https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"type": "started",
"phase": "score",
"done": 123,
"total": 123,
"run": {
"id": "<string>",
"status": "running",
"startedMs": 123,
"candidates": 123,
"recommendations": 123,
"simulated": 123,
"forecastsUsed": 123,
"budget": 123,
"finishedMs": 123,
"skippedExisting": 123,
"skippedDismissed": 123
},
"recommendation": {
"key": "<string>",
"ruleType": "relative_flow_count",
"rule": {
"version": 1,
"type": "relative_flow_count",
"window": "<string>",
"conditions": [
{
"severity": "info",
"operator": "above",
"threshold": 123
}
],
"groupBy": [
"<string>"
],
"filters": [
{}
],
"maxInstances": 250,
"settings": {},
"recovery": {
"operator": "above",
"threshold": 123
},
"for": "<string>",
"noData": "ok",
"evaluationHours": {
"mode": "always",
"timezone": "<string>",
"ranges": [
{
"weekdays": [
"mon"
],
"start": "09:00",
"end": "18:00"
}
]
},
"overrides": [
{
"match": {},
"conditions": [
{
"severity": "info",
"operator": "above",
"threshold": 123
}
],
"recovery": {
"operator": "above",
"threshold": 123
},
"for": "<string>",
"noData": "ok",
"settings": {},
"evaluationHours": {
"mode": "always",
"timezone": "<string>",
"ranges": [
{
"weekdays": [
"mon"
],
"start": "09:00",
"end": "18:00"
}
]
}
}
]
},
"label": "<string>",
"position": 123,
"status": "simulated",
"variant": "<string>",
"days": 123,
"perSlot": 123,
"coverage": {
"groups": 123,
"alertableGroups": 123,
"coveredShare": 123,
"largestShare": 123,
"hiddenShare": 123
},
"dimensions": [
{
"dimension": "<string>",
"name": "<string>",
"coverage": {
"groups": 123,
"alertableGroups": 123,
"coveredShare": 123,
"largestShare": 123,
"hiddenShare": 123
},
"recommended": true,
"reason": "no_volume"
}
],
"daily": [
123
],
"groups": [
{
"value": "<string>",
"perSlot": 123,
"share": 123,
"daysPresent": 123,
"alertable": true,
"daily": [
123
],
"otherGroups": 123,
"otherAlertableGroups": 123,
"dailyRate": [
123
],
"fired": 123,
"firedPerHour": [
123
]
}
],
"notSimulatedReason": "budget",
"dimension": "<string>",
"dimensionName": "<string>",
"fromMs": 123,
"toMs": 123,
"dailyRate": [
123
],
"simulation": {
"fired": 123,
"days": 123,
"groups": [
{
"labels": {},
"fired": 123
}
],
"refinementComplete": true,
"forecasts": 123,
"topGroups": 123,
"fromMs": 123,
"toMs": 123,
"firedPerHour": [
123
]
}
},
"message": "<string>"
}{
"error": {
"message": "Validation failed",
"details": [
{
"field": "projectID",
"message": "required"
}
]
}
}Generate alert recommendations
Recommends alert rules for the project from its traffic and streams the progress and every recommendation
as soon as it is decided, as application/x-ndjson. The result is stored: it replaces the project’s
earlier recommendations and is what GET /observe/alertRecommendations returns.
What is recommended: forecast_kpi rules on the flows counted and the success rate of every flow type the
project has 5-minute data for. A KPI is recommended when it has at least about five flows per 5-minute
bucket on each of the last 7 complete days: its rule over all flows, and a rule grouped by each of its at
most three best dimensions (application, browser, operating system or a custom tag). A dimension is a good
grouping when at least two of its groups have enough flows on every day to be judged, those groups hold at
least half of the flows and no group holds 90% or more; dimensions whose groups would hide a drop in the
whole (groups below 30% of the flows) rank first. Rules the project has already (same type, KPI and
grouping, however tuned) and dismissed recommendations are left out.
Every recommendation is then simulated with the rule type’s defaults over the last 1 or 2 days, as the
rule form simulates, in the order of the list, as long as the generation’s simulation budget (20,000
forecasts) and its time limit (10 minutes) last. A grouped rule whose groups do not fit is simulated in its
largest groups only (simulation.topGroups). The rest are returned with status not_simulated and a
reason; the rule form simulates them on request.
Events, one JSON object per line: started first (with run), progress as phases advance (repeated
while nothing else happens, so the connection never idles), recommendation for each recommendation,
and finished (with run) or error last. Closing the connection cancels the generation; its partial
results are discarded.
One generation per project runs at a time (409), and a project may start one 10 minutes after its last
finished at the earliest (429 with Retry-After); the stored recommendations are what to show meanwhile.
When the service runs as many generations as it may, it answers 429 too.
Required API key permission: observe:alerts:write.
curl --request POST \
--url https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloud.corbado.io/v1/observe/alertRecommendations/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"type": "started",
"phase": "score",
"done": 123,
"total": 123,
"run": {
"id": "<string>",
"status": "running",
"startedMs": 123,
"candidates": 123,
"recommendations": 123,
"simulated": 123,
"forecastsUsed": 123,
"budget": 123,
"finishedMs": 123,
"skippedExisting": 123,
"skippedDismissed": 123
},
"recommendation": {
"key": "<string>",
"ruleType": "relative_flow_count",
"rule": {
"version": 1,
"type": "relative_flow_count",
"window": "<string>",
"conditions": [
{
"severity": "info",
"operator": "above",
"threshold": 123
}
],
"groupBy": [
"<string>"
],
"filters": [
{}
],
"maxInstances": 250,
"settings": {},
"recovery": {
"operator": "above",
"threshold": 123
},
"for": "<string>",
"noData": "ok",
"evaluationHours": {
"mode": "always",
"timezone": "<string>",
"ranges": [
{
"weekdays": [
"mon"
],
"start": "09:00",
"end": "18:00"
}
]
},
"overrides": [
{
"match": {},
"conditions": [
{
"severity": "info",
"operator": "above",
"threshold": 123
}
],
"recovery": {
"operator": "above",
"threshold": 123
},
"for": "<string>",
"noData": "ok",
"settings": {},
"evaluationHours": {
"mode": "always",
"timezone": "<string>",
"ranges": [
{
"weekdays": [
"mon"
],
"start": "09:00",
"end": "18:00"
}
]
}
}
]
},
"label": "<string>",
"position": 123,
"status": "simulated",
"variant": "<string>",
"days": 123,
"perSlot": 123,
"coverage": {
"groups": 123,
"alertableGroups": 123,
"coveredShare": 123,
"largestShare": 123,
"hiddenShare": 123
},
"dimensions": [
{
"dimension": "<string>",
"name": "<string>",
"coverage": {
"groups": 123,
"alertableGroups": 123,
"coveredShare": 123,
"largestShare": 123,
"hiddenShare": 123
},
"recommended": true,
"reason": "no_volume"
}
],
"daily": [
123
],
"groups": [
{
"value": "<string>",
"perSlot": 123,
"share": 123,
"daysPresent": 123,
"alertable": true,
"daily": [
123
],
"otherGroups": 123,
"otherAlertableGroups": 123,
"dailyRate": [
123
],
"fired": 123,
"firedPerHour": [
123
]
}
],
"notSimulatedReason": "budget",
"dimension": "<string>",
"dimensionName": "<string>",
"fromMs": 123,
"toMs": 123,
"dailyRate": [
123
],
"simulation": {
"fired": 123,
"days": 123,
"groups": [
{
"labels": {},
"fired": 123
}
],
"refinementComplete": true,
"forecasts": 123,
"topGroups": 123,
"fromMs": 123,
"toMs": 123,
"firedPerHour": [
123
]
}
},
"message": "<string>"
}{
"error": {
"message": "Validation failed",
"details": [
{
"field": "projectID",
"message": "required"
}
]
}
}Authorizations
Response
Newline-delimited JSON stream of the generation's events.
One line of a generation's stream.
Was this page helpful?