The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Cost Monitoring & Alerts",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 1
}
]
}
},
"name": "Hourly Schedule",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"url": "http://prometheus:9090/api/v1/query",
"qs": {
"query": "sum(api_gateway_cost_total)"
}
},
"name": "Query Total Costs",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
450,
300
]
},
{
"parameters": {
"url": "http://prometheus:9090/api/v1/query",
"qs": {
"query": "sum(rate(api_gateway_cost_total[1h])) * 730"
}
},
"name": "Query Monthly Projection",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
450,
450
]
},
{
"parameters": {
"functionCode": "// Calculate cost metrics\nconst totalCost = parseFloat($input.first().json.data.result[0]?.value[1] || 0);\nconst monthlyProjection = parseFloat($input.last().json.data.result[0]?.value[1] || 0);\n\n// Thresholds\nconst DAILY_THRESHOLD = 10; // $10/day\nconst MONTHLY_THRESHOLD = 200; // $200/month\n\nconst alert = {\n total_cost: totalCost.toFixed(2),\n monthly_projection: monthlyProjection.toFixed(2),\n daily_threshold_exceeded: totalCost > DAILY_THRESHOLD,\n monthly_threshold_exceeded: monthlyProjection > MONTHLY_THRESHOLD,\n timestamp: new Date().toISOString()\n};\n\nreturn alert;"
},
"name": "Calculate Metrics",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
650,
375
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.daily_threshold_exceeded || $json.monthly_threshold_exceeded }}",
"value2": true
}
]
}
},
"name": "Check Thresholds",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
850,
375
]
},
{
"parameters": {
"functionCode": "// Format alert message\nconst message = `\ud83d\udea8 API Cost Alert!\\n\\nTotal Cost: $${$json.total_cost}\\nMonthly Projection: $${$json.monthly_projection}\\n\\nTime to optimize routing!\\n\\nTimestamp: ${$json.timestamp}`;\n\nreturn { message };"
},
"name": "Format Alert",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
1050,
375
]
}
],
"connections": {
"Hourly Schedule": {
"main": [
[
{
"node": "Query Total Costs",
"type": "main",
"index": 0
},
{
"node": "Query Monthly Projection",
"type": "main",
"index": 0
}
]
]
},
"Query Total Costs": {
"main": [
[
{
"node": "Calculate Metrics",
"type": "main",
"index": 0
}
]
]
},
"Query Monthly Projection": {
"main": [
[
{
"node": "Calculate Metrics",
"type": "main",
"index": 0
}
]
]
},
"Calculate Metrics": {
"main": [
[
{
"node": "Check Thresholds",
"type": "main",
"index": 0
}
]
]
},
"Check Thresholds": {
"main": [
[
{
"node": "Format Alert",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "1"
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Cost Monitoring & Alerts. Uses httpRequest. Scheduled trigger; 6 nodes.
Source: https://github.com/jeremylongshore/Hybrid-ai-stack-intent-solutions/blob/f1cd251518a4afeb9dc8841b700851199340bc8a/workflows/cost_monitor.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Proactively alert to service endpoint changes and pod/container issues (Pending, Not Ready, Restart spikes) using Prometheus metrics, formatted and sent to Slack.
Tired of being let down by the Google Drive Trigger? Rather not exhaust system resources by polling every minute? Then this workflow is for you!
Triggers at a regular interval or via a webhook request. Solves AWS WAF challenge then makes a request to fetch the product page. Extracts product data from the retrieved HTML page. Compares the curre
Automatically monitor billable Kimai projects every weekday morning and receive a formatted HTML email when a project deadline is approaching or its hour budget is running low. If nothing requires att
Transform your business with intelligent deal monitoring and automated customer engagement! This AI-powered coupon aggregator continuously tracks competitor deals and creates personalized marketing ca