API稼働時間監視の自動化と即時ダウンalert
これはDevOps分野の自動化ワークフローで、17個のノードを含みます。主にIf, Code, Wait, WhatsApp, HttpRequestなどのノードを使用。 API稼働時間監視、WhatsAppアラート付き、Googleスheets管理
- •ターゲットAPIの認証情報が必要な場合あり
- •Google Sheets API認証情報
カテゴリー
{
"id": "pc2HHg8DLhcpoMg5",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "Automated API Uptime Monitoring with Instant Downtime Alerts",
"tags": [],
"nodes": [
{
"id": "6050fae8-e86d-481f-bcf5-98461f796b5f",
"name": "APIリストの読み込み",
"type": "n8n-nodes-base.googleSheets",
"position": [
-2640,
260
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1VKlDZSHicdZhhj-fl-vIIH0mC6VDwdCS4-LqaDIeyw0/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1VKlDZSHicdZhhj-fl-vIIH0mC6VDwdCS4-LqaDIeyw0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1VKlDZSHicdZhhj-fl-vIIH0mC6VDwdCS4-LqaDIeyw0/edit?usp=drivesdk",
"cachedResultName": "URL For Status Check"
},
"combineFilters": "AND"
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "rgIk6EXVdPbmPYAl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.2
},
{
"id": "68940a15-d216-4366-8673-71b71305084d",
"name": "リトライカウンターの初期化",
"type": "n8n-nodes-base.code",
"position": [
-2200,
185
],
"parameters": {
"jsCode": "// Initialize retry counter for each API\nconst apiData = $json;\nif (!apiData.retryCount) {\n apiData.retryCount = 0;\n}\nreturn apiData;"
},
"typeVersion": 2
},
{
"id": "06b0731a-81c3-449f-b302-0e9f5e2f9b0d",
"name": "APIのテスト",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1980,
185
],
"parameters": {
"url": "={{ $json.url }}",
"method": "={{ $json.method }}",
"options": {
"timeout": 10000
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2,
"continueOnFail": true
},
{
"id": "f4450c0b-48fe-40d2-9b68-c54b12980a01",
"name": "レスポンスの確認",
"type": "n8n-nodes-base.code",
"position": [
-1760,
185
],
"parameters": {
"jsCode": "// Check if API responded\nconst response = $json;\nconst apiData = $('Init Retry Counter').first().json;\n\nlet hasResponse = response && typeof response === 'object' && Object.keys(response).length > 0;\n\nreturn {\n ...apiData,\n hasResponse: hasResponse\n};"
},
"typeVersion": 2
},
{
"id": "886d69dd-e847-4cf7-badb-5d5a02e8cfcd",
"name": "レスポンスがない場合",
"type": "n8n-nodes-base.if",
"position": [
-1540,
185
],
"parameters": {
"options": {
"looseTypeValidation": true
},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "no-response",
"operator": {
"type": "boolean",
"operation": "true"
},
"leftValue": "={{ $json.hasResponse }}",
"rightValue": "=false"
}
]
}
},
"typeVersion": 2
},
{
"id": "be9792e7-be19-47e3-9621-613f1cc8d611",
"name": "10分待機",
"type": "n8n-nodes-base.wait",
"position": [
-1320,
110
],
"webhookId": "b89a5cda-2fa5-40ad-b534-ed607a47c847",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "4fdd9d39-af72-42d7-9d81-0e878920709b",
"name": "リトライ回数の増分",
"type": "n8n-nodes-base.code",
"position": [
-1100,
35
],
"parameters": {
"jsCode": "// Increment retry count\nconst data = $json;\ndata.retryCount = (data.retryCount || 0) + 1;\nreturn data;"
},
"typeVersion": 2
},
{
"id": "c71871bb-7416-4a58-b5b6-d0c326856c62",
"name": "APIをリトライ",
"type": "n8n-nodes-base.httpRequest",
"position": [
-880,
35
],
"parameters": {
"url": "={{ $json.url }}",
"method": "={{ $json.method }}",
"options": {
"timeout": 10000
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2,
"continueOnFail": true
},
{
"id": "5567bff2-495e-4b96-adbc-9d5aa290398a",
"name": "リトライレスポンスの確認",
"type": "n8n-nodes-base.code",
"position": [
-660,
35
],
"parameters": {
"jsCode": "// Check retry response\nconst response = $json;\nconst apiData = $('Increment Retry').first().json;\n\nlet hasResponse = response && typeof response === 'object' && Object.keys(response).length > 0;\n\nreturn {\n ...apiData,\n hasResponse: hasResponse\n};"
},
"typeVersion": 2
},
{
"id": "56590da0-6e35-430b-b380-066322cdb528",
"name": "まだ応答がない場合",
"type": "n8n-nodes-base.if",
"position": [
-440,
35
],
"parameters": {
"options": {
"looseTypeValidation": true
},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "still-no-response",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.expectedStatusCode === null || $json.expectedStatusCode === undefined || $json.expectedStatusCode === '' }}",
"rightValue": "=false"
}
]
}
},
"typeVersion": 2
},
{
"id": "1c206215-fe56-48f6-87f0-e1875e664d80",
"name": "ダウンアラートの整形",
"type": "n8n-nodes-base.code",
"position": [
0,
-40
],
"parameters": {
"jsCode": "// Create down alert message\nconst api = $json;\n\nconst alertMessage = `🚨 API DOWN ALERT\\n\\n📋 ${api.name}\\n🌐 ${api.url}\\n⏰ ${new Date().toISOString()}`;\n\nreturn {\n ...api,\n alertMessage: alertMessage\n};"
},
"typeVersion": 2
},
{
"id": "96024d21-5201-4629-9eef-547c49994d4f",
"name": "WhatsAppアラートの送信",
"type": "n8n-nodes-base.whatsApp",
"position": [
220,
-40
],
"webhookId": "b8bca051-44db-4578-a849-6fdf7559609d",
"parameters": {
"textBody": "={{ $json.alertMessage }}",
"operation": "send",
"phoneNumberId": "550325331503475",
"additionalFields": {},
"recipientPhoneNumber": "+919974388925"
},
"credentials": {
"whatsAppApi": {
"id": "3hy4gzpVJrY1sFcR",
"name": "WhatsApp account API"
}
},
"typeVersion": 1
},
{
"id": "42753397-1223-4fc5-8df0-a340a64fc731",
"name": "次のAPIへ",
"type": "n8n-nodes-base.code",
"position": [
440,
260
],
"parameters": {
"jsCode": "// Continue to next API\nconst data = $json;\nif (data.hasResponse) {\n data.retryCount = 0;\n}\nreturn data;"
},
"typeVersion": 2
},
{
"id": "1f5c7218-68d3-4878-a238-36ca0ad31764",
"name": "各API1の処理",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-2420,
260
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "0b1af6a3-bf8e-4398-917e-f2526449ad6b",
"name": "リトライ > 4 の場合",
"type": "n8n-nodes-base.if",
"position": [
-220,
-40
],
"parameters": {
"options": {
"looseTypeValidation": true
},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "still-no-response",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.retryCount >= 4}}",
"rightValue": "=false"
}
]
}
},
"typeVersion": 2
},
{
"id": "d2bb51d4-2ace-4a9c-8a7c-25c588de3063",
"name": "トリガーのスケジュール設定",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-2860,
260
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 15
}
]
}
},
"typeVersion": 1.1
},
{
"id": "3fda8d5d-5311-4804-afef-4ec25ed3c92f",
"name": "付箋",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2420,
-340
],
"parameters": {
"color": 4,
"width": 1220,
"height": 340,
"content": "## How It Works\n* **Schedule Trigger** → Triggers every 15 minutes.\n* **Read API List** → Fetches all API URLs from a Google Sheet.\n* **Process Each API1** → Loops through each API entry.\n* **Init Retry Counter** → Initializes `retryCount = 0`.\n* **Test API** → Sends the first request to the API.\n* **Check Response** → Checks if a valid response was received.\n* **If No Response** → Branches into retry flow if down.\n* **Wait 10 Min → Increment Retry → Retry API → Check Retry Response** → Wait and retry API call once.\n* **If Still No Response** → Verifies if retry also failed.\n* **If Still No Retry > 4** → Checks if retry limit is reached (≥ 4).\n* **Format Down Alert** → Formats the WhatsApp alert with API details.\n* **Send WhatsApp Alert** → Sends API down alert to configured number.\n* **Continue Next API** → Moves to the next API in the list."
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "2eee3704-de38-4436-9d22-57252c0ff118",
"connections": {
"06b0731a-81c3-449f-b302-0e9f5e2f9b0d": {
"main": [
[
{
"node": "f4450c0b-48fe-40d2-9b68-c54b12980a01",
"type": "main",
"index": 0
}
]
]
},
"c71871bb-7416-4a58-b5b6-d0c326856c62": {
"main": [
[
{
"node": "5567bff2-495e-4b96-adbc-9d5aa290398a",
"type": "main",
"index": 0
}
]
]
},
"be9792e7-be19-47e3-9621-613f1cc8d611": {
"main": [
[
{
"node": "4fdd9d39-af72-42d7-9d81-0e878920709b",
"type": "main",
"index": 0
}
]
]
},
"6050fae8-e86d-481f-bcf5-98461f796b5f": {
"main": [
[
{
"node": "1f5c7218-68d3-4878-a238-36ca0ad31764",
"type": "main",
"index": 0
}
]
]
},
"f4450c0b-48fe-40d2-9b68-c54b12980a01": {
"main": [
[
{
"node": "886d69dd-e847-4cf7-badb-5d5a02e8cfcd",
"type": "main",
"index": 0
}
]
]
},
"886d69dd-e847-4cf7-badb-5d5a02e8cfcd": {
"main": [
[
{
"node": "be9792e7-be19-47e3-9621-613f1cc8d611",
"type": "main",
"index": 0
}
],
[
{
"node": "42753397-1223-4fc5-8df0-a340a64fc731",
"type": "main",
"index": 0
}
]
]
},
"4fdd9d39-af72-42d7-9d81-0e878920709b": {
"main": [
[
{
"node": "c71871bb-7416-4a58-b5b6-d0c326856c62",
"type": "main",
"index": 0
}
]
]
},
"d2bb51d4-2ace-4a9c-8a7c-25c588de3063": {
"main": [
[
{
"node": "6050fae8-e86d-481f-bcf5-98461f796b5f",
"type": "main",
"index": 0
}
]
]
},
"42753397-1223-4fc5-8df0-a340a64fc731": {
"main": [
[
{
"node": "1f5c7218-68d3-4878-a238-36ca0ad31764",
"type": "main",
"index": 0
}
]
]
},
"1c206215-fe56-48f6-87f0-e1875e664d80": {
"main": [
[
{
"node": "96024d21-5201-4629-9eef-547c49994d4f",
"type": "main",
"index": 0
}
]
]
},
"1f5c7218-68d3-4878-a238-36ca0ad31764": {
"main": [
[],
[
{
"node": "68940a15-d216-4366-8673-71b71305084d",
"type": "main",
"index": 0
}
]
]
},
"68940a15-d216-4366-8673-71b71305084d": {
"main": [
[
{
"node": "06b0731a-81c3-449f-b302-0e9f5e2f9b0d",
"type": "main",
"index": 0
}
]
]
},
"96024d21-5201-4629-9eef-547c49994d4f": {
"main": [
[
{
"node": "42753397-1223-4fc5-8df0-a340a64fc731",
"type": "main",
"index": 0
}
]
]
},
"5567bff2-495e-4b96-adbc-9d5aa290398a": {
"main": [
[
{
"node": "56590da0-6e35-430b-b380-066322cdb528",
"type": "main",
"index": 0
}
]
]
},
"56590da0-6e35-430b-b380-066322cdb528": {
"main": [
[
{
"node": "0b1af6a3-bf8e-4398-917e-f2526449ad6b",
"type": "main",
"index": 0
}
],
[
{
"node": "42753397-1223-4fc5-8df0-a340a64fc731",
"type": "main",
"index": 0
}
]
]
},
"0b1af6a3-bf8e-4398-917e-f2526449ad6b": {
"main": [
[
{
"node": "1c206215-fe56-48f6-87f0-e1875e664d80",
"type": "main",
"index": 0
}
],
[
{
"node": "be9792e7-be19-47e3-9621-613f1cc8d611",
"type": "main",
"index": 0
}
]
]
}
}
}このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
上級 - DevOps
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
このワークフローを共有