Alerts
Create/Update Alert
Create a new alert based on the provided configuration or update an existing one if the alert.metadata.id matches an existing alert.
POST
/
alerts
/
update
Create/Update Alert
curl --request POST \
--url https://us-east.metoro.io/api/v1/alerts/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"alert": {
"metadata": {
"name": "name",
"description": "description",
"id": "123e4567-e89b-12d3-a456-426614174000"
},
"timeseries": {
"expression": {
"metoroQLTimeseries": {
"query": "count(traces)",
"bucketSize": 60
}
},
"evaluationRules": [
{
"static": {
"persistenceSettings": {
"datapointsToAlarm": 3,
"missingDatapointBehavior": "notBreaching",
"datapointsInEvaluationWindow": 5
},
"operators": [
{
"threshold": 5000,
"operator": "greaterThan"
}
]
},
"name": "name",
"type": "static",
"actions": [
{
"slackDestination": {
"channel": "my-alerts-channel"
},
"type": "slack"
},
{
"emailDestination": {
"emails": [
"user@example.com",
"admin@example.com"
]
},
"type": "email"
}
]
}
]
},
"type": "timeseries"
}
}
'import requests
url = "https://us-east.metoro.io/api/v1/alerts/update"
payload = { "alert": {
"metadata": {
"name": "name",
"description": "description",
"id": "123e4567-e89b-12d3-a456-426614174000"
},
"timeseries": {
"expression": { "metoroQLTimeseries": {
"query": "count(traces)",
"bucketSize": 60
} },
"evaluationRules": [
{
"static": {
"persistenceSettings": {
"datapointsToAlarm": 3,
"missingDatapointBehavior": "notBreaching",
"datapointsInEvaluationWindow": 5
},
"operators": [
{
"threshold": 5000,
"operator": "greaterThan"
}
]
},
"name": "name",
"type": "static",
"actions": [
{
"slackDestination": { "channel": "my-alerts-channel" },
"type": "slack"
},
{
"emailDestination": { "emails": ["user@example.com", "admin@example.com"] },
"type": "email"
}
]
}
]
},
"type": "timeseries"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
alert: {
metadata: {
name: 'name',
description: 'description',
id: '123e4567-e89b-12d3-a456-426614174000'
},
timeseries: {
expression: {metoroQLTimeseries: {query: 'count(traces)', bucketSize: 60}},
evaluationRules: [
{
static: {
persistenceSettings: {
datapointsToAlarm: 3,
missingDatapointBehavior: 'notBreaching',
datapointsInEvaluationWindow: 5
},
operators: [{threshold: 5000, operator: 'greaterThan'}]
},
name: 'name',
type: 'static',
actions: [
{slackDestination: {channel: 'my-alerts-channel'}, type: 'slack'},
{
emailDestination: {emails: ['user@example.com', 'admin@example.com']},
type: 'email'
}
]
}
]
},
type: 'timeseries'
}
})
};
fetch('https://us-east.metoro.io/api/v1/alerts/update', 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://us-east.metoro.io/api/v1/alerts/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'alert' => [
'metadata' => [
'name' => 'name',
'description' => 'description',
'id' => '123e4567-e89b-12d3-a456-426614174000'
],
'timeseries' => [
'expression' => [
'metoroQLTimeseries' => [
'query' => 'count(traces)',
'bucketSize' => 60
]
],
'evaluationRules' => [
[
'static' => [
'persistenceSettings' => [
'datapointsToAlarm' => 3,
'missingDatapointBehavior' => 'notBreaching',
'datapointsInEvaluationWindow' => 5
],
'operators' => [
[
'threshold' => 5000,
'operator' => 'greaterThan'
]
]
],
'name' => 'name',
'type' => 'static',
'actions' => [
[
'slackDestination' => [
'channel' => 'my-alerts-channel'
],
'type' => 'slack'
],
[
'emailDestination' => [
'emails' => [
'user@example.com',
'admin@example.com'
]
],
'type' => 'email'
]
]
]
]
],
'type' => 'timeseries'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://us-east.metoro.io/api/v1/alerts/update"
payload := strings.NewReader("{\n \"alert\": {\n \"metadata\": {\n \"name\": \"name\",\n \"description\": \"description\",\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n \"timeseries\": {\n \"expression\": {\n \"metoroQLTimeseries\": {\n \"query\": \"count(traces)\",\n \"bucketSize\": 60\n }\n },\n \"evaluationRules\": [\n {\n \"static\": {\n \"persistenceSettings\": {\n \"datapointsToAlarm\": 3,\n \"missingDatapointBehavior\": \"notBreaching\",\n \"datapointsInEvaluationWindow\": 5\n },\n \"operators\": [\n {\n \"threshold\": 5000,\n \"operator\": \"greaterThan\"\n }\n ]\n },\n \"name\": \"name\",\n \"type\": \"static\",\n \"actions\": [\n {\n \"slackDestination\": {\n \"channel\": \"my-alerts-channel\"\n },\n \"type\": \"slack\"\n },\n {\n \"emailDestination\": {\n \"emails\": [\n \"user@example.com\",\n \"admin@example.com\"\n ]\n },\n \"type\": \"email\"\n }\n ]\n }\n ]\n },\n \"type\": \"timeseries\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://us-east.metoro.io/api/v1/alerts/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"alert\": {\n \"metadata\": {\n \"name\": \"name\",\n \"description\": \"description\",\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n \"timeseries\": {\n \"expression\": {\n \"metoroQLTimeseries\": {\n \"query\": \"count(traces)\",\n \"bucketSize\": 60\n }\n },\n \"evaluationRules\": [\n {\n \"static\": {\n \"persistenceSettings\": {\n \"datapointsToAlarm\": 3,\n \"missingDatapointBehavior\": \"notBreaching\",\n \"datapointsInEvaluationWindow\": 5\n },\n \"operators\": [\n {\n \"threshold\": 5000,\n \"operator\": \"greaterThan\"\n }\n ]\n },\n \"name\": \"name\",\n \"type\": \"static\",\n \"actions\": [\n {\n \"slackDestination\": {\n \"channel\": \"my-alerts-channel\"\n },\n \"type\": \"slack\"\n },\n {\n \"emailDestination\": {\n \"emails\": [\n \"user@example.com\",\n \"admin@example.com\"\n ]\n },\n \"type\": \"email\"\n }\n ]\n }\n ]\n },\n \"type\": \"timeseries\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us-east.metoro.io/api/v1/alerts/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"alert\": {\n \"metadata\": {\n \"name\": \"name\",\n \"description\": \"description\",\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n \"timeseries\": {\n \"expression\": {\n \"metoroQLTimeseries\": {\n \"query\": \"count(traces)\",\n \"bucketSize\": 60\n }\n },\n \"evaluationRules\": [\n {\n \"static\": {\n \"persistenceSettings\": {\n \"datapointsToAlarm\": 3,\n \"missingDatapointBehavior\": \"notBreaching\",\n \"datapointsInEvaluationWindow\": 5\n },\n \"operators\": [\n {\n \"threshold\": 5000,\n \"operator\": \"greaterThan\"\n }\n ]\n },\n \"name\": \"name\",\n \"type\": \"static\",\n \"actions\": [\n {\n \"slackDestination\": {\n \"channel\": \"my-alerts-channel\"\n },\n \"type\": \"slack\"\n },\n {\n \"emailDestination\": {\n \"emails\": [\n \"user@example.com\",\n \"admin@example.com\"\n ]\n },\n \"type\": \"email\"\n }\n ]\n }\n ]\n },\n \"type\": \"timeseries\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000"
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Alert to create or update
Request to create a new alert or update an existing one. If alert.metadata.id is provided and matches an existing alert, that alert will be updated.
Show child attributes
Show child attributes
Example:
{
"metadata": {
"name": "name",
"description": "description",
"id": "123e4567-e89b-12d3-a456-426614174000"
},
"type": "timeseries",
"investigateOnFire": false,
"timeseries": {
"expression": {
"metoroQLTimeseries": {
"query": "count(traces)",
"bucketSize": 60
}
},
"evaluationRules": [
{
"static": {
"persistenceSettings": {
"datapointsToAlarm": 3,
"missingDatapointBehavior": "notBreaching",
"datapointsInEvaluationWindow": 5
},
"operators": [
{
"threshold": 5000,
"operator": "greaterThan"
}
]
},
"name": "name",
"type": "static",
"actions": [
{
"slackDestination": { "channel": "my-alerts-channel" },
"type": "slack"
},
{
"emailDestination": {
"emails": ["user@example.com", "admin@example.com"]
},
"type": "email"
}
]
}
]
}
}
Response
Alert created or updated successfully
Unique identifier for the created or updated alert
Was this page helpful?
⌘I
Create/Update Alert
curl --request POST \
--url https://us-east.metoro.io/api/v1/alerts/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"alert": {
"metadata": {
"name": "name",
"description": "description",
"id": "123e4567-e89b-12d3-a456-426614174000"
},
"timeseries": {
"expression": {
"metoroQLTimeseries": {
"query": "count(traces)",
"bucketSize": 60
}
},
"evaluationRules": [
{
"static": {
"persistenceSettings": {
"datapointsToAlarm": 3,
"missingDatapointBehavior": "notBreaching",
"datapointsInEvaluationWindow": 5
},
"operators": [
{
"threshold": 5000,
"operator": "greaterThan"
}
]
},
"name": "name",
"type": "static",
"actions": [
{
"slackDestination": {
"channel": "my-alerts-channel"
},
"type": "slack"
},
{
"emailDestination": {
"emails": [
"user@example.com",
"admin@example.com"
]
},
"type": "email"
}
]
}
]
},
"type": "timeseries"
}
}
'import requests
url = "https://us-east.metoro.io/api/v1/alerts/update"
payload = { "alert": {
"metadata": {
"name": "name",
"description": "description",
"id": "123e4567-e89b-12d3-a456-426614174000"
},
"timeseries": {
"expression": { "metoroQLTimeseries": {
"query": "count(traces)",
"bucketSize": 60
} },
"evaluationRules": [
{
"static": {
"persistenceSettings": {
"datapointsToAlarm": 3,
"missingDatapointBehavior": "notBreaching",
"datapointsInEvaluationWindow": 5
},
"operators": [
{
"threshold": 5000,
"operator": "greaterThan"
}
]
},
"name": "name",
"type": "static",
"actions": [
{
"slackDestination": { "channel": "my-alerts-channel" },
"type": "slack"
},
{
"emailDestination": { "emails": ["user@example.com", "admin@example.com"] },
"type": "email"
}
]
}
]
},
"type": "timeseries"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
alert: {
metadata: {
name: 'name',
description: 'description',
id: '123e4567-e89b-12d3-a456-426614174000'
},
timeseries: {
expression: {metoroQLTimeseries: {query: 'count(traces)', bucketSize: 60}},
evaluationRules: [
{
static: {
persistenceSettings: {
datapointsToAlarm: 3,
missingDatapointBehavior: 'notBreaching',
datapointsInEvaluationWindow: 5
},
operators: [{threshold: 5000, operator: 'greaterThan'}]
},
name: 'name',
type: 'static',
actions: [
{slackDestination: {channel: 'my-alerts-channel'}, type: 'slack'},
{
emailDestination: {emails: ['user@example.com', 'admin@example.com']},
type: 'email'
}
]
}
]
},
type: 'timeseries'
}
})
};
fetch('https://us-east.metoro.io/api/v1/alerts/update', 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://us-east.metoro.io/api/v1/alerts/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'alert' => [
'metadata' => [
'name' => 'name',
'description' => 'description',
'id' => '123e4567-e89b-12d3-a456-426614174000'
],
'timeseries' => [
'expression' => [
'metoroQLTimeseries' => [
'query' => 'count(traces)',
'bucketSize' => 60
]
],
'evaluationRules' => [
[
'static' => [
'persistenceSettings' => [
'datapointsToAlarm' => 3,
'missingDatapointBehavior' => 'notBreaching',
'datapointsInEvaluationWindow' => 5
],
'operators' => [
[
'threshold' => 5000,
'operator' => 'greaterThan'
]
]
],
'name' => 'name',
'type' => 'static',
'actions' => [
[
'slackDestination' => [
'channel' => 'my-alerts-channel'
],
'type' => 'slack'
],
[
'emailDestination' => [
'emails' => [
'user@example.com',
'admin@example.com'
]
],
'type' => 'email'
]
]
]
]
],
'type' => 'timeseries'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://us-east.metoro.io/api/v1/alerts/update"
payload := strings.NewReader("{\n \"alert\": {\n \"metadata\": {\n \"name\": \"name\",\n \"description\": \"description\",\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n \"timeseries\": {\n \"expression\": {\n \"metoroQLTimeseries\": {\n \"query\": \"count(traces)\",\n \"bucketSize\": 60\n }\n },\n \"evaluationRules\": [\n {\n \"static\": {\n \"persistenceSettings\": {\n \"datapointsToAlarm\": 3,\n \"missingDatapointBehavior\": \"notBreaching\",\n \"datapointsInEvaluationWindow\": 5\n },\n \"operators\": [\n {\n \"threshold\": 5000,\n \"operator\": \"greaterThan\"\n }\n ]\n },\n \"name\": \"name\",\n \"type\": \"static\",\n \"actions\": [\n {\n \"slackDestination\": {\n \"channel\": \"my-alerts-channel\"\n },\n \"type\": \"slack\"\n },\n {\n \"emailDestination\": {\n \"emails\": [\n \"user@example.com\",\n \"admin@example.com\"\n ]\n },\n \"type\": \"email\"\n }\n ]\n }\n ]\n },\n \"type\": \"timeseries\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://us-east.metoro.io/api/v1/alerts/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"alert\": {\n \"metadata\": {\n \"name\": \"name\",\n \"description\": \"description\",\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n \"timeseries\": {\n \"expression\": {\n \"metoroQLTimeseries\": {\n \"query\": \"count(traces)\",\n \"bucketSize\": 60\n }\n },\n \"evaluationRules\": [\n {\n \"static\": {\n \"persistenceSettings\": {\n \"datapointsToAlarm\": 3,\n \"missingDatapointBehavior\": \"notBreaching\",\n \"datapointsInEvaluationWindow\": 5\n },\n \"operators\": [\n {\n \"threshold\": 5000,\n \"operator\": \"greaterThan\"\n }\n ]\n },\n \"name\": \"name\",\n \"type\": \"static\",\n \"actions\": [\n {\n \"slackDestination\": {\n \"channel\": \"my-alerts-channel\"\n },\n \"type\": \"slack\"\n },\n {\n \"emailDestination\": {\n \"emails\": [\n \"user@example.com\",\n \"admin@example.com\"\n ]\n },\n \"type\": \"email\"\n }\n ]\n }\n ]\n },\n \"type\": \"timeseries\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us-east.metoro.io/api/v1/alerts/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"alert\": {\n \"metadata\": {\n \"name\": \"name\",\n \"description\": \"description\",\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\"\n },\n \"timeseries\": {\n \"expression\": {\n \"metoroQLTimeseries\": {\n \"query\": \"count(traces)\",\n \"bucketSize\": 60\n }\n },\n \"evaluationRules\": [\n {\n \"static\": {\n \"persistenceSettings\": {\n \"datapointsToAlarm\": 3,\n \"missingDatapointBehavior\": \"notBreaching\",\n \"datapointsInEvaluationWindow\": 5\n },\n \"operators\": [\n {\n \"threshold\": 5000,\n \"operator\": \"greaterThan\"\n }\n ]\n },\n \"name\": \"name\",\n \"type\": \"static\",\n \"actions\": [\n {\n \"slackDestination\": {\n \"channel\": \"my-alerts-channel\"\n },\n \"type\": \"slack\"\n },\n {\n \"emailDestination\": {\n \"emails\": [\n \"user@example.com\",\n \"admin@example.com\"\n ]\n },\n \"type\": \"email\"\n }\n ]\n }\n ]\n },\n \"type\": \"timeseries\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000"
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}{
"error": "Invalid alert configuration: missing required field"
}