Alerts
Create an alert
Creates a threshold alert on logs, spans, or a metric. While the value is past the threshold, the alert posts once to its Slack channel and posts the recovery in the same thread.
POST
/
alerts
Create an alert
curl --request POST \
--url https://superlog.sh/api/v1/alerts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"threshold": 123,
"name": "<string>",
"field": "<string>",
"filter": {
"metricUnit": "<string>",
"minDurationMs": 1800000,
"resourceAttrs": [
{
"key": "<string>",
"value": "<string>"
}
],
"service": "<string>",
"severity": "<string>",
"spanName": "<string>",
"statusCode": "<string>"
},
"groupBy": "<string>",
"metricName": "<string>",
"windowMinutes": 720,
"enabled": true,
"evaluationIntervalSeconds": 1830,
"slack": {
"channelId": "<string>",
"integrationAccountId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}
'import requests
url = "https://superlog.sh/api/v1/alerts"
payload = {
"threshold": 123,
"name": "<string>",
"field": "<string>",
"filter": {
"metricUnit": "<string>",
"minDurationMs": 1800000,
"resourceAttrs": [
{
"key": "<string>",
"value": "<string>"
}
],
"service": "<string>",
"severity": "<string>",
"spanName": "<string>",
"statusCode": "<string>"
},
"groupBy": "<string>",
"metricName": "<string>",
"windowMinutes": 720,
"enabled": True,
"evaluationIntervalSeconds": 1830,
"slack": {
"channelId": "<string>",
"integrationAccountId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}
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({
threshold: 123,
name: '<string>',
field: '<string>',
filter: {
metricUnit: '<string>',
minDurationMs: 1800000,
resourceAttrs: [{key: '<string>', value: '<string>'}],
service: '<string>',
severity: '<string>',
spanName: '<string>',
statusCode: '<string>'
},
groupBy: '<string>',
metricName: '<string>',
windowMinutes: 720,
enabled: true,
evaluationIntervalSeconds: 1830,
slack: {
channelId: '<string>',
integrationAccountId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
})
};
fetch('https://superlog.sh/api/v1/alerts', 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://superlog.sh/api/v1/alerts",
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([
'threshold' => 123,
'name' => '<string>',
'field' => '<string>',
'filter' => [
'metricUnit' => '<string>',
'minDurationMs' => 1800000,
'resourceAttrs' => [
[
'key' => '<string>',
'value' => '<string>'
]
],
'service' => '<string>',
'severity' => '<string>',
'spanName' => '<string>',
'statusCode' => '<string>'
],
'groupBy' => '<string>',
'metricName' => '<string>',
'windowMinutes' => 720,
'enabled' => true,
'evaluationIntervalSeconds' => 1830,
'slack' => [
'channelId' => '<string>',
'integrationAccountId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]),
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://superlog.sh/api/v1/alerts"
payload := strings.NewReader("{\n \"threshold\": 123,\n \"name\": \"<string>\",\n \"field\": \"<string>\",\n \"filter\": {\n \"metricUnit\": \"<string>\",\n \"minDurationMs\": 1800000,\n \"resourceAttrs\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"service\": \"<string>\",\n \"severity\": \"<string>\",\n \"spanName\": \"<string>\",\n \"statusCode\": \"<string>\"\n },\n \"groupBy\": \"<string>\",\n \"metricName\": \"<string>\",\n \"windowMinutes\": 720,\n \"enabled\": true,\n \"evaluationIntervalSeconds\": 1830,\n \"slack\": {\n \"channelId\": \"<string>\",\n \"integrationAccountId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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://superlog.sh/api/v1/alerts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"threshold\": 123,\n \"name\": \"<string>\",\n \"field\": \"<string>\",\n \"filter\": {\n \"metricUnit\": \"<string>\",\n \"minDurationMs\": 1800000,\n \"resourceAttrs\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"service\": \"<string>\",\n \"severity\": \"<string>\",\n \"spanName\": \"<string>\",\n \"statusCode\": \"<string>\"\n },\n \"groupBy\": \"<string>\",\n \"metricName\": \"<string>\",\n \"windowMinutes\": 720,\n \"enabled\": true,\n \"evaluationIntervalSeconds\": 1830,\n \"slack\": {\n \"channelId\": \"<string>\",\n \"integrationAccountId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://superlog.sh/api/v1/alerts")
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 \"threshold\": 123,\n \"name\": \"<string>\",\n \"field\": \"<string>\",\n \"filter\": {\n \"metricUnit\": \"<string>\",\n \"minDurationMs\": 1800000,\n \"resourceAttrs\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"service\": \"<string>\",\n \"severity\": \"<string>\",\n \"spanName\": \"<string>\",\n \"statusCode\": \"<string>\"\n },\n \"groupBy\": \"<string>\",\n \"metricName\": \"<string>\",\n \"windowMinutes\": 720,\n \"enabled\": true,\n \"evaluationIntervalSeconds\": 1830,\n \"slack\": {\n \"channelId\": \"<string>\",\n \"integrationAccountId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n}"
response = http.request(request)
puts response.read_body{
"alert": {
"aggregation": "count",
"comparator": "gt",
"field": "<string>",
"filter": {
"metricKind": "gauge",
"metricUnit": "<string>",
"minDurationMs": 1800000,
"resourceAttrs": [
{
"key": "<string>",
"value": "<string>",
"op": "eq"
}
],
"service": "<string>",
"severity": "<string>",
"spanName": "<string>",
"statusCode": "<string>"
},
"groupBy": "<string>",
"groupMode": "single",
"metricName": "<string>",
"source": "logs",
"threshold": 123,
"windowMinutes": 720,
"createdAt": "<string>",
"enabled": true,
"evaluationIntervalSeconds": 123,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lastError": "<string>",
"lastEvaluatedAt": "<string>",
"name": "<string>",
"slack": {
"channelId": "<string>",
"integrationAccountId": "<string>"
},
"updatedAt": "<string>",
"url": "<string>"
}
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}Authorizations
Body
application/json
⌘I
Create an alert
curl --request POST \
--url https://superlog.sh/api/v1/alerts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"threshold": 123,
"name": "<string>",
"field": "<string>",
"filter": {
"metricUnit": "<string>",
"minDurationMs": 1800000,
"resourceAttrs": [
{
"key": "<string>",
"value": "<string>"
}
],
"service": "<string>",
"severity": "<string>",
"spanName": "<string>",
"statusCode": "<string>"
},
"groupBy": "<string>",
"metricName": "<string>",
"windowMinutes": 720,
"enabled": true,
"evaluationIntervalSeconds": 1830,
"slack": {
"channelId": "<string>",
"integrationAccountId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}
'import requests
url = "https://superlog.sh/api/v1/alerts"
payload = {
"threshold": 123,
"name": "<string>",
"field": "<string>",
"filter": {
"metricUnit": "<string>",
"minDurationMs": 1800000,
"resourceAttrs": [
{
"key": "<string>",
"value": "<string>"
}
],
"service": "<string>",
"severity": "<string>",
"spanName": "<string>",
"statusCode": "<string>"
},
"groupBy": "<string>",
"metricName": "<string>",
"windowMinutes": 720,
"enabled": True,
"evaluationIntervalSeconds": 1830,
"slack": {
"channelId": "<string>",
"integrationAccountId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}
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({
threshold: 123,
name: '<string>',
field: '<string>',
filter: {
metricUnit: '<string>',
minDurationMs: 1800000,
resourceAttrs: [{key: '<string>', value: '<string>'}],
service: '<string>',
severity: '<string>',
spanName: '<string>',
statusCode: '<string>'
},
groupBy: '<string>',
metricName: '<string>',
windowMinutes: 720,
enabled: true,
evaluationIntervalSeconds: 1830,
slack: {
channelId: '<string>',
integrationAccountId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
})
};
fetch('https://superlog.sh/api/v1/alerts', 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://superlog.sh/api/v1/alerts",
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([
'threshold' => 123,
'name' => '<string>',
'field' => '<string>',
'filter' => [
'metricUnit' => '<string>',
'minDurationMs' => 1800000,
'resourceAttrs' => [
[
'key' => '<string>',
'value' => '<string>'
]
],
'service' => '<string>',
'severity' => '<string>',
'spanName' => '<string>',
'statusCode' => '<string>'
],
'groupBy' => '<string>',
'metricName' => '<string>',
'windowMinutes' => 720,
'enabled' => true,
'evaluationIntervalSeconds' => 1830,
'slack' => [
'channelId' => '<string>',
'integrationAccountId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]),
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://superlog.sh/api/v1/alerts"
payload := strings.NewReader("{\n \"threshold\": 123,\n \"name\": \"<string>\",\n \"field\": \"<string>\",\n \"filter\": {\n \"metricUnit\": \"<string>\",\n \"minDurationMs\": 1800000,\n \"resourceAttrs\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"service\": \"<string>\",\n \"severity\": \"<string>\",\n \"spanName\": \"<string>\",\n \"statusCode\": \"<string>\"\n },\n \"groupBy\": \"<string>\",\n \"metricName\": \"<string>\",\n \"windowMinutes\": 720,\n \"enabled\": true,\n \"evaluationIntervalSeconds\": 1830,\n \"slack\": {\n \"channelId\": \"<string>\",\n \"integrationAccountId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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://superlog.sh/api/v1/alerts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"threshold\": 123,\n \"name\": \"<string>\",\n \"field\": \"<string>\",\n \"filter\": {\n \"metricUnit\": \"<string>\",\n \"minDurationMs\": 1800000,\n \"resourceAttrs\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"service\": \"<string>\",\n \"severity\": \"<string>\",\n \"spanName\": \"<string>\",\n \"statusCode\": \"<string>\"\n },\n \"groupBy\": \"<string>\",\n \"metricName\": \"<string>\",\n \"windowMinutes\": 720,\n \"enabled\": true,\n \"evaluationIntervalSeconds\": 1830,\n \"slack\": {\n \"channelId\": \"<string>\",\n \"integrationAccountId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://superlog.sh/api/v1/alerts")
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 \"threshold\": 123,\n \"name\": \"<string>\",\n \"field\": \"<string>\",\n \"filter\": {\n \"metricUnit\": \"<string>\",\n \"minDurationMs\": 1800000,\n \"resourceAttrs\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"service\": \"<string>\",\n \"severity\": \"<string>\",\n \"spanName\": \"<string>\",\n \"statusCode\": \"<string>\"\n },\n \"groupBy\": \"<string>\",\n \"metricName\": \"<string>\",\n \"windowMinutes\": 720,\n \"enabled\": true,\n \"evaluationIntervalSeconds\": 1830,\n \"slack\": {\n \"channelId\": \"<string>\",\n \"integrationAccountId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n}"
response = http.request(request)
puts response.read_body{
"alert": {
"aggregation": "count",
"comparator": "gt",
"field": "<string>",
"filter": {
"metricKind": "gauge",
"metricUnit": "<string>",
"minDurationMs": 1800000,
"resourceAttrs": [
{
"key": "<string>",
"value": "<string>",
"op": "eq"
}
],
"service": "<string>",
"severity": "<string>",
"spanName": "<string>",
"statusCode": "<string>"
},
"groupBy": "<string>",
"groupMode": "single",
"metricName": "<string>",
"source": "logs",
"threshold": 123,
"windowMinutes": 720,
"createdAt": "<string>",
"enabled": true,
"evaluationIntervalSeconds": 123,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lastError": "<string>",
"lastEvaluatedAt": "<string>",
"name": "<string>",
"slack": {
"channelId": "<string>",
"integrationAccountId": "<string>"
},
"updatedAt": "<string>",
"url": "<string>"
}
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}{
"error": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
]
}
]
}