Create a cost alert
curl --request POST \
--url https://api.example.com/alerts-v2/costAlerts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production compute spend increased 20% week over week",
"description": "Notify FinOps when the seven-day AWS compute run rate materially increases.",
"urlState": "metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS",
"currency": "USD",
"queries": [
{
"type": "cost",
"name": "a",
"alias": "Production AWS compute",
"aggregator": "SUM",
"metricId": "cost",
"currency": "USD",
"groupBy": "cos_service_name",
"whereClause": {
"combinator": "and",
"rules": [
{
"field": "cos_provider",
"operator": "in",
"value": [
"AWS"
]
},
{
"field": "cos_environment",
"operator": "in",
"value": [
"production"
]
},
{
"field": "cos_service_name",
"operator": "in",
"value": [
"AmazonEC2",
"AmazonRDS"
]
}
]
},
"visible": true,
"colorIndex": 0,
"chartType": "LINE"
}
],
"condition": "rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000",
"dedup": {
"kind": "CALENDAR",
"calendarUnit": "WEEK"
},
"thresholds": [],
"notificationChannel": "EMAIL",
"emails": [
"finops@acme.com",
"cloud-platform@acme.com"
],
"tagIds": []
}
'import requests
url = "https://api.example.com/alerts-v2/costAlerts"
payload = {
"name": "Production compute spend increased 20% week over week",
"description": "Notify FinOps when the seven-day AWS compute run rate materially increases.",
"urlState": "metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS",
"currency": "USD",
"queries": [
{
"type": "cost",
"name": "a",
"alias": "Production AWS compute",
"aggregator": "SUM",
"metricId": "cost",
"currency": "USD",
"groupBy": "cos_service_name",
"whereClause": {
"combinator": "and",
"rules": [
{
"field": "cos_provider",
"operator": "in",
"value": ["AWS"]
},
{
"field": "cos_environment",
"operator": "in",
"value": ["production"]
},
{
"field": "cos_service_name",
"operator": "in",
"value": ["AmazonEC2", "AmazonRDS"]
}
]
},
"visible": True,
"colorIndex": 0,
"chartType": "LINE"
}
],
"condition": "rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000",
"dedup": {
"kind": "CALENDAR",
"calendarUnit": "WEEK"
},
"thresholds": [],
"notificationChannel": "EMAIL",
"emails": ["finops@acme.com", "cloud-platform@acme.com"],
"tagIds": []
}
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({
name: 'Production compute spend increased 20% week over week',
description: 'Notify FinOps when the seven-day AWS compute run rate materially increases.',
urlState: 'metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS',
currency: 'USD',
queries: [
{
type: 'cost',
name: 'a',
alias: 'Production AWS compute',
aggregator: 'SUM',
metricId: 'cost',
currency: 'USD',
groupBy: 'cos_service_name',
whereClause: {
combinator: 'and',
rules: [
{field: 'cos_provider', operator: 'in', value: ['AWS']},
{field: 'cos_environment', operator: 'in', value: ['production']},
{field: 'cos_service_name', operator: 'in', value: ['AmazonEC2', 'AmazonRDS']}
]
},
visible: true,
colorIndex: 0,
chartType: 'LINE'
}
],
condition: 'rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000',
dedup: {kind: 'CALENDAR', calendarUnit: 'WEEK'},
thresholds: [],
notificationChannel: 'EMAIL',
emails: ['finops@acme.com', 'cloud-platform@acme.com'],
tagIds: []
})
};
fetch('https://api.example.com/alerts-v2/costAlerts', 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.example.com/alerts-v2/costAlerts",
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([
'name' => 'Production compute spend increased 20% week over week',
'description' => 'Notify FinOps when the seven-day AWS compute run rate materially increases.',
'urlState' => 'metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS',
'currency' => 'USD',
'queries' => [
[
'type' => 'cost',
'name' => 'a',
'alias' => 'Production AWS compute',
'aggregator' => 'SUM',
'metricId' => 'cost',
'currency' => 'USD',
'groupBy' => 'cos_service_name',
'whereClause' => [
'combinator' => 'and',
'rules' => [
[
'field' => 'cos_provider',
'operator' => 'in',
'value' => [
'AWS'
]
],
[
'field' => 'cos_environment',
'operator' => 'in',
'value' => [
'production'
]
],
[
'field' => 'cos_service_name',
'operator' => 'in',
'value' => [
'AmazonEC2',
'AmazonRDS'
]
]
]
],
'visible' => true,
'colorIndex' => 0,
'chartType' => 'LINE'
]
],
'condition' => 'rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000',
'dedup' => [
'kind' => 'CALENDAR',
'calendarUnit' => 'WEEK'
],
'thresholds' => [
],
'notificationChannel' => 'EMAIL',
'emails' => [
'finops@acme.com',
'cloud-platform@acme.com'
],
'tagIds' => [
]
]),
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://api.example.com/alerts-v2/costAlerts"
payload := strings.NewReader("{\n \"name\": \"Production compute spend increased 20% week over week\",\n \"description\": \"Notify FinOps when the seven-day AWS compute run rate materially increases.\",\n \"urlState\": \"metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS\",\n \"currency\": \"USD\",\n \"queries\": [\n {\n \"type\": \"cost\",\n \"name\": \"a\",\n \"alias\": \"Production AWS compute\",\n \"aggregator\": \"SUM\",\n \"metricId\": \"cost\",\n \"currency\": \"USD\",\n \"groupBy\": \"cos_service_name\",\n \"whereClause\": {\n \"combinator\": \"and\",\n \"rules\": [\n {\n \"field\": \"cos_provider\",\n \"operator\": \"in\",\n \"value\": [\n \"AWS\"\n ]\n },\n {\n \"field\": \"cos_environment\",\n \"operator\": \"in\",\n \"value\": [\n \"production\"\n ]\n },\n {\n \"field\": \"cos_service_name\",\n \"operator\": \"in\",\n \"value\": [\n \"AmazonEC2\",\n \"AmazonRDS\"\n ]\n }\n ]\n },\n \"visible\": true,\n \"colorIndex\": 0,\n \"chartType\": \"LINE\"\n }\n ],\n \"condition\": \"rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000\",\n \"dedup\": {\n \"kind\": \"CALENDAR\",\n \"calendarUnit\": \"WEEK\"\n },\n \"thresholds\": [],\n \"notificationChannel\": \"EMAIL\",\n \"emails\": [\n \"finops@acme.com\",\n \"cloud-platform@acme.com\"\n ],\n \"tagIds\": []\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://api.example.com/alerts-v2/costAlerts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production compute spend increased 20% week over week\",\n \"description\": \"Notify FinOps when the seven-day AWS compute run rate materially increases.\",\n \"urlState\": \"metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS\",\n \"currency\": \"USD\",\n \"queries\": [\n {\n \"type\": \"cost\",\n \"name\": \"a\",\n \"alias\": \"Production AWS compute\",\n \"aggregator\": \"SUM\",\n \"metricId\": \"cost\",\n \"currency\": \"USD\",\n \"groupBy\": \"cos_service_name\",\n \"whereClause\": {\n \"combinator\": \"and\",\n \"rules\": [\n {\n \"field\": \"cos_provider\",\n \"operator\": \"in\",\n \"value\": [\n \"AWS\"\n ]\n },\n {\n \"field\": \"cos_environment\",\n \"operator\": \"in\",\n \"value\": [\n \"production\"\n ]\n },\n {\n \"field\": \"cos_service_name\",\n \"operator\": \"in\",\n \"value\": [\n \"AmazonEC2\",\n \"AmazonRDS\"\n ]\n }\n ]\n },\n \"visible\": true,\n \"colorIndex\": 0,\n \"chartType\": \"LINE\"\n }\n ],\n \"condition\": \"rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000\",\n \"dedup\": {\n \"kind\": \"CALENDAR\",\n \"calendarUnit\": \"WEEK\"\n },\n \"thresholds\": [],\n \"notificationChannel\": \"EMAIL\",\n \"emails\": [\n \"finops@acme.com\",\n \"cloud-platform@acme.com\"\n ],\n \"tagIds\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/alerts-v2/costAlerts")
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 \"name\": \"Production compute spend increased 20% week over week\",\n \"description\": \"Notify FinOps when the seven-day AWS compute run rate materially increases.\",\n \"urlState\": \"metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS\",\n \"currency\": \"USD\",\n \"queries\": [\n {\n \"type\": \"cost\",\n \"name\": \"a\",\n \"alias\": \"Production AWS compute\",\n \"aggregator\": \"SUM\",\n \"metricId\": \"cost\",\n \"currency\": \"USD\",\n \"groupBy\": \"cos_service_name\",\n \"whereClause\": {\n \"combinator\": \"and\",\n \"rules\": [\n {\n \"field\": \"cos_provider\",\n \"operator\": \"in\",\n \"value\": [\n \"AWS\"\n ]\n },\n {\n \"field\": \"cos_environment\",\n \"operator\": \"in\",\n \"value\": [\n \"production\"\n ]\n },\n {\n \"field\": \"cos_service_name\",\n \"operator\": \"in\",\n \"value\": [\n \"AmazonEC2\",\n \"AmazonRDS\"\n ]\n }\n ]\n },\n \"visible\": true,\n \"colorIndex\": 0,\n \"chartType\": \"LINE\"\n }\n ],\n \"condition\": \"rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000\",\n \"dedup\": {\n \"kind\": \"CALENDAR\",\n \"calendarUnit\": \"WEEK\"\n },\n \"thresholds\": [],\n \"notificationChannel\": \"EMAIL\",\n \"emails\": [\n \"finops@acme.com\",\n \"cloud-platform@acme.com\"\n ],\n \"tagIds\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"organizationId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"createdById": "<string>",
"archivedAt": "2023-11-07T05:31:56Z",
"scopeId": "<string>",
"urlState": "<string>",
"name": "<string>",
"queryName": "<string>",
"queries": [
{
"type": "condition",
"expression": "<string>",
"name": "<string>",
"colorIndex": 123,
"alias": "<string>",
"visible": true
}
],
"snoozedUntil": "2023-11-07T05:31:56Z",
"condition": "<string>",
"conditionAdvancedExplorerQuery": {},
"dedupWindowDays": 123,
"emails": [
"jsmith@example.com"
],
"slackChannelId": "<string>",
"teamsChannelId": "<string>",
"description": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Alerts V2
Create a cost alert
Creates either a condition-based alert (condition plus dedup) or a legacy threshold-based alert. The example monitors production AWS compute spend using Costory dimensions.
POST
/
alerts-v2
/
costAlerts
Create a cost alert
curl --request POST \
--url https://api.example.com/alerts-v2/costAlerts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production compute spend increased 20% week over week",
"description": "Notify FinOps when the seven-day AWS compute run rate materially increases.",
"urlState": "metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS",
"currency": "USD",
"queries": [
{
"type": "cost",
"name": "a",
"alias": "Production AWS compute",
"aggregator": "SUM",
"metricId": "cost",
"currency": "USD",
"groupBy": "cos_service_name",
"whereClause": {
"combinator": "and",
"rules": [
{
"field": "cos_provider",
"operator": "in",
"value": [
"AWS"
]
},
{
"field": "cos_environment",
"operator": "in",
"value": [
"production"
]
},
{
"field": "cos_service_name",
"operator": "in",
"value": [
"AmazonEC2",
"AmazonRDS"
]
}
]
},
"visible": true,
"colorIndex": 0,
"chartType": "LINE"
}
],
"condition": "rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000",
"dedup": {
"kind": "CALENDAR",
"calendarUnit": "WEEK"
},
"thresholds": [],
"notificationChannel": "EMAIL",
"emails": [
"finops@acme.com",
"cloud-platform@acme.com"
],
"tagIds": []
}
'import requests
url = "https://api.example.com/alerts-v2/costAlerts"
payload = {
"name": "Production compute spend increased 20% week over week",
"description": "Notify FinOps when the seven-day AWS compute run rate materially increases.",
"urlState": "metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS",
"currency": "USD",
"queries": [
{
"type": "cost",
"name": "a",
"alias": "Production AWS compute",
"aggregator": "SUM",
"metricId": "cost",
"currency": "USD",
"groupBy": "cos_service_name",
"whereClause": {
"combinator": "and",
"rules": [
{
"field": "cos_provider",
"operator": "in",
"value": ["AWS"]
},
{
"field": "cos_environment",
"operator": "in",
"value": ["production"]
},
{
"field": "cos_service_name",
"operator": "in",
"value": ["AmazonEC2", "AmazonRDS"]
}
]
},
"visible": True,
"colorIndex": 0,
"chartType": "LINE"
}
],
"condition": "rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000",
"dedup": {
"kind": "CALENDAR",
"calendarUnit": "WEEK"
},
"thresholds": [],
"notificationChannel": "EMAIL",
"emails": ["finops@acme.com", "cloud-platform@acme.com"],
"tagIds": []
}
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({
name: 'Production compute spend increased 20% week over week',
description: 'Notify FinOps when the seven-day AWS compute run rate materially increases.',
urlState: 'metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS',
currency: 'USD',
queries: [
{
type: 'cost',
name: 'a',
alias: 'Production AWS compute',
aggregator: 'SUM',
metricId: 'cost',
currency: 'USD',
groupBy: 'cos_service_name',
whereClause: {
combinator: 'and',
rules: [
{field: 'cos_provider', operator: 'in', value: ['AWS']},
{field: 'cos_environment', operator: 'in', value: ['production']},
{field: 'cos_service_name', operator: 'in', value: ['AmazonEC2', 'AmazonRDS']}
]
},
visible: true,
colorIndex: 0,
chartType: 'LINE'
}
],
condition: 'rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000',
dedup: {kind: 'CALENDAR', calendarUnit: 'WEEK'},
thresholds: [],
notificationChannel: 'EMAIL',
emails: ['finops@acme.com', 'cloud-platform@acme.com'],
tagIds: []
})
};
fetch('https://api.example.com/alerts-v2/costAlerts', 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.example.com/alerts-v2/costAlerts",
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([
'name' => 'Production compute spend increased 20% week over week',
'description' => 'Notify FinOps when the seven-day AWS compute run rate materially increases.',
'urlState' => 'metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS',
'currency' => 'USD',
'queries' => [
[
'type' => 'cost',
'name' => 'a',
'alias' => 'Production AWS compute',
'aggregator' => 'SUM',
'metricId' => 'cost',
'currency' => 'USD',
'groupBy' => 'cos_service_name',
'whereClause' => [
'combinator' => 'and',
'rules' => [
[
'field' => 'cos_provider',
'operator' => 'in',
'value' => [
'AWS'
]
],
[
'field' => 'cos_environment',
'operator' => 'in',
'value' => [
'production'
]
],
[
'field' => 'cos_service_name',
'operator' => 'in',
'value' => [
'AmazonEC2',
'AmazonRDS'
]
]
]
],
'visible' => true,
'colorIndex' => 0,
'chartType' => 'LINE'
]
],
'condition' => 'rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000',
'dedup' => [
'kind' => 'CALENDAR',
'calendarUnit' => 'WEEK'
],
'thresholds' => [
],
'notificationChannel' => 'EMAIL',
'emails' => [
'finops@acme.com',
'cloud-platform@acme.com'
],
'tagIds' => [
]
]),
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://api.example.com/alerts-v2/costAlerts"
payload := strings.NewReader("{\n \"name\": \"Production compute spend increased 20% week over week\",\n \"description\": \"Notify FinOps when the seven-day AWS compute run rate materially increases.\",\n \"urlState\": \"metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS\",\n \"currency\": \"USD\",\n \"queries\": [\n {\n \"type\": \"cost\",\n \"name\": \"a\",\n \"alias\": \"Production AWS compute\",\n \"aggregator\": \"SUM\",\n \"metricId\": \"cost\",\n \"currency\": \"USD\",\n \"groupBy\": \"cos_service_name\",\n \"whereClause\": {\n \"combinator\": \"and\",\n \"rules\": [\n {\n \"field\": \"cos_provider\",\n \"operator\": \"in\",\n \"value\": [\n \"AWS\"\n ]\n },\n {\n \"field\": \"cos_environment\",\n \"operator\": \"in\",\n \"value\": [\n \"production\"\n ]\n },\n {\n \"field\": \"cos_service_name\",\n \"operator\": \"in\",\n \"value\": [\n \"AmazonEC2\",\n \"AmazonRDS\"\n ]\n }\n ]\n },\n \"visible\": true,\n \"colorIndex\": 0,\n \"chartType\": \"LINE\"\n }\n ],\n \"condition\": \"rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000\",\n \"dedup\": {\n \"kind\": \"CALENDAR\",\n \"calendarUnit\": \"WEEK\"\n },\n \"thresholds\": [],\n \"notificationChannel\": \"EMAIL\",\n \"emails\": [\n \"finops@acme.com\",\n \"cloud-platform@acme.com\"\n ],\n \"tagIds\": []\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://api.example.com/alerts-v2/costAlerts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production compute spend increased 20% week over week\",\n \"description\": \"Notify FinOps when the seven-day AWS compute run rate materially increases.\",\n \"urlState\": \"metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS\",\n \"currency\": \"USD\",\n \"queries\": [\n {\n \"type\": \"cost\",\n \"name\": \"a\",\n \"alias\": \"Production AWS compute\",\n \"aggregator\": \"SUM\",\n \"metricId\": \"cost\",\n \"currency\": \"USD\",\n \"groupBy\": \"cos_service_name\",\n \"whereClause\": {\n \"combinator\": \"and\",\n \"rules\": [\n {\n \"field\": \"cos_provider\",\n \"operator\": \"in\",\n \"value\": [\n \"AWS\"\n ]\n },\n {\n \"field\": \"cos_environment\",\n \"operator\": \"in\",\n \"value\": [\n \"production\"\n ]\n },\n {\n \"field\": \"cos_service_name\",\n \"operator\": \"in\",\n \"value\": [\n \"AmazonEC2\",\n \"AmazonRDS\"\n ]\n }\n ]\n },\n \"visible\": true,\n \"colorIndex\": 0,\n \"chartType\": \"LINE\"\n }\n ],\n \"condition\": \"rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000\",\n \"dedup\": {\n \"kind\": \"CALENDAR\",\n \"calendarUnit\": \"WEEK\"\n },\n \"thresholds\": [],\n \"notificationChannel\": \"EMAIL\",\n \"emails\": [\n \"finops@acme.com\",\n \"cloud-platform@acme.com\"\n ],\n \"tagIds\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/alerts-v2/costAlerts")
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 \"name\": \"Production compute spend increased 20% week over week\",\n \"description\": \"Notify FinOps when the seven-day AWS compute run rate materially increases.\",\n \"urlState\": \"metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS\",\n \"currency\": \"USD\",\n \"queries\": [\n {\n \"type\": \"cost\",\n \"name\": \"a\",\n \"alias\": \"Production AWS compute\",\n \"aggregator\": \"SUM\",\n \"metricId\": \"cost\",\n \"currency\": \"USD\",\n \"groupBy\": \"cos_service_name\",\n \"whereClause\": {\n \"combinator\": \"and\",\n \"rules\": [\n {\n \"field\": \"cos_provider\",\n \"operator\": \"in\",\n \"value\": [\n \"AWS\"\n ]\n },\n {\n \"field\": \"cos_environment\",\n \"operator\": \"in\",\n \"value\": [\n \"production\"\n ]\n },\n {\n \"field\": \"cos_service_name\",\n \"operator\": \"in\",\n \"value\": [\n \"AmazonEC2\",\n \"AmazonRDS\"\n ]\n }\n ]\n },\n \"visible\": true,\n \"colorIndex\": 0,\n \"chartType\": \"LINE\"\n }\n ],\n \"condition\": \"rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY) * 1.2 and rollingSum(a, 7, DAY) > 12000\",\n \"dedup\": {\n \"kind\": \"CALENDAR\",\n \"calendarUnit\": \"WEEK\"\n },\n \"thresholds\": [],\n \"notificationChannel\": \"EMAIL\",\n \"emails\": [\n \"finops@acme.com\",\n \"cloud-platform@acme.com\"\n ],\n \"tagIds\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"organizationId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"createdById": "<string>",
"archivedAt": "2023-11-07T05:31:56Z",
"scopeId": "<string>",
"urlState": "<string>",
"name": "<string>",
"queryName": "<string>",
"queries": [
{
"type": "condition",
"expression": "<string>",
"name": "<string>",
"colorIndex": 123,
"alias": "<string>",
"visible": true
}
],
"snoozedUntil": "2023-11-07T05:31:56Z",
"condition": "<string>",
"conditionAdvancedExplorerQuery": {},
"dedupWindowDays": 123,
"emails": [
"jsmith@example.com"
],
"slackChannelId": "<string>",
"teamsChannelId": "<string>",
"description": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Send Authorization: Bearer <credential> using either a Clerk session JWT or a Clerk API key (ak_*). API keys may identify a user (user_*) or organization (org_*) principal and are generated in the Clerk Dashboard under API keys.
Body
application/json
- Option 1
- Option 2
- Option 3
Minimum string length:
1Available options:
USD, EUR, GBP, CNY - Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
Show child attributes
Show child attributes
Available options:
SLACK Minimum string length:
1Show child attributes
Show child attributes
Available options:
DAILY, WEEKLY, MONTHLY Available options:
ABOVE, UNDER Show child attributes
Show child attributes
Response
Cost alert created
Available options:
USD, EUR, GBP, CNY - Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
Show child attributes
Show child attributes
Available options:
DAILY, WEEKLY, MONTHLY Available options:
ABOVE, UNDER Show child attributes
Show child attributes
Available options:
CALENDAR, ROLLING, null Available options:
WEEK, MONTH, null Available options:
EMAIL, SLACK, TEAMS Last modified on August 10, 2026
Was this page helpful?
⌘I
