{ "displayName": "pilot-tls-check", "schemaVersion": "26", "notes": [], "trigger": { "name": "trigger", "valid": true, "displayName": "Every minute (pilot)", "nextAction": { "name": "step_1", "type": "CODE", "valid": true, "settings": { "input": {}, "sourceCode": { "code": "export const code = async () => [{host:'tls.pilot',port:8443},{host:'tls.pilot',port:8444}];", "packageJson": "{}" }, "sourceCodeHash": "", "propertySettings": {}, "errorHandlingOptions": { "retryOnFailure": { "value": false }, "continueOnFailure": { "value": false } } }, "nextAction": { "name": "step_2", "type": "LOOP_ON_ITEMS", "valid": true, "settings": { "items": "{{step_1['output']}}", "propertySettings": {} }, "displayName": "For each target", "firstLoopAction": { "name": "step_3", "type": "PIECE", "valid": true, "settings": { "input": { "url": "http://checker:8000/check/tls", "method": "GET", "headers": {}, "timeout": 10, "authType": "NONE", "body_type": "none", "use_proxy": false, "authFields": {}, "failureMode": "retry_5xx", "queryParams": { "host": "{{step_2['output'].item.host}}", "port": "{{step_2['output'].item.port}}" }, "proxy_settings": {}, "followRedirects": false, "response_is_binary": false }, "pieceName": "@activepieces/piece-http", "actionName": "send_request", "pieceVersion": "0.12.1", "propertySettings": { "url": { "type": "MANUAL" }, "method": { "type": "MANUAL" }, "headers": { "type": "MANUAL" }, "timeout": { "type": "MANUAL" }, "authType": { "type": "MANUAL" }, "body_type": { "type": "MANUAL" }, "use_proxy": { "type": "MANUAL" }, "authFields": { "type": "MANUAL" }, "failureMode": { "type": "MANUAL" }, "queryParams": { "type": "MANUAL" }, "proxy_settings": { "type": "MANUAL" }, "followRedirects": { "type": "MANUAL" }, "response_is_binary": { "type": "MANUAL" } }, "errorHandlingOptions": { "retryOnFailure": { "value": true }, "continueOnFailure": { "value": false } } }, "nextAction": { "name": "step_4", "type": "PIECE", "valid": true, "settings": { "input": { "key": "tls:{{step_2['output'].item.host}}:{{step_2['output'].item.port}}", "store_scope": "FLOW" }, "pieceName": "@activepieces/piece-store", "actionName": "get", "pieceVersion": "0.6.20", "propertySettings": { "key": { "type": "MANUAL" }, "store_scope": { "type": "MANUAL" } }, "errorHandlingOptions": { "retryOnFailure": { "value": false }, "continueOnFailure": { "value": false } } }, "nextAction": { "name": "step_5", "type": "CODE", "valid": true, "settings": { "input": { "prev": "{{step_4['output']}}", "result": "{{step_3['output'].body}}", "target": "{{step_2['output'].item.host}}:{{step_2['output'].item.port}}", "reminderMinutes": "720" }, "sourceCode": { "code": "export const code = async (inputs) => {\n // Alert state machine (ops-automation-phase1 design D4): alert on a state change only after\n // TWO consecutive identical results; one recovery message; reminder while critical stays open.\n const REMINDER_MS = Number(inputs.reminderMinutes ?? 720) * 60000;\n let result;\n try { result = typeof inputs.result === 'string' ? JSON.parse(inputs.result) : inputs.result; } catch { result = null; }\n if (!result || !result.status) result = { status: 'critical', check: 'checker', target: String(inputs.target || 'unknown'), values: { error: 'checker unreachable or invalid response' } };\n let prev = inputs.prev;\n if (typeof prev === 'string') { try { prev = JSON.parse(prev); } catch { prev = null; } }\n const now = new Date().toISOString();\n const cur = result.status;\n const state = prev && prev.status ? prev\n : { status: 'ok', since: now, lastAlertAt: null, pending: null, pendingCount: 0 };\n let next = { ...state };\n let alert = null;\n if (cur === state.status) {\n next.pending = null; next.pendingCount = 0;\n if (cur === 'critical' && state.lastAlertAt && Date.parse(now) - Date.parse(state.lastAlertAt) >= REMINDER_MS) {\n alert = { kind: 'reminder', level: 'critical' }; next.lastAlertAt = now;\n }\n } else if (cur === 'ok') {\n next = { status: 'ok', since: now, lastAlertAt: null, pending: null, pendingCount: 0 };\n alert = { kind: 'recovery', level: 'ok' };\n } else {\n if (state.pending === cur) next.pendingCount = (state.pendingCount || 0) + 1;\n else { next.pending = cur; next.pendingCount = 1; }\n if (next.pendingCount >= 2) {\n next = { status: cur, since: now, lastAlertAt: now, pending: null, pendingCount: 0 };\n alert = { kind: 'change', level: cur };\n }\n }\n const title = alert ? `[${alert.level}] ${result.check} ${result.target}` : '';\n const message = alert ? `${alert.kind}: ${JSON.stringify(result.values)}` : '';\n return { nextJson: JSON.stringify(next), hasAlert: !!alert, title, message, status: cur };\n};\n", "packageJson": "{}" }, "sourceCodeHash": "", "propertySettings": { "prev": { "type": "MANUAL" }, "result": { "type": "MANUAL" }, "reminderMinutes": { "type": "MANUAL" } }, "errorHandlingOptions": { "retryOnFailure": { "value": false }, "continueOnFailure": { "value": false } } }, "nextAction": { "name": "step_6", "type": "PIECE", "valid": true, "settings": { "input": { "key": "tls:{{step_2['output'].item.host}}:{{step_2['output'].item.port}}", "value": "{{step_5['output'].nextJson}}", "store_scope": "FLOW" }, "pieceName": "@activepieces/piece-store", "actionName": "put", "pieceVersion": "0.6.20", "propertySettings": { "key": { "type": "MANUAL" }, "value": { "type": "MANUAL" }, "store_scope": { "type": "MANUAL" } }, "errorHandlingOptions": { "retryOnFailure": { "value": false }, "continueOnFailure": { "value": false } } }, "nextAction": { "name": "step_7", "type": "ROUTER", "valid": true, "children": [ { "name": "step_8", "type": "PIECE", "valid": true, "settings": { "input": { "url": "http://ntfy-sink:8000/infra-alerts", "body": { "data": "{{step_5['output'].message}}" }, "method": "POST", "headers": { "Title": "{{step_5['output'].title}}", "Priority": "high" }, "timeout": 10, "authType": "NONE", "body_type": "raw", "use_proxy": false, "authFields": {}, "failureMode": "retry_5xx", "queryParams": {}, "proxy_settings": {}, "followRedirects": false, "response_is_binary": false }, "pieceName": "@activepieces/piece-http", "actionName": "send_request", "pieceVersion": "0.12.1", "propertySettings": { "url": { "type": "MANUAL" }, "body": { "type": "MANUAL" }, "method": { "type": "MANUAL" }, "headers": { "type": "MANUAL" }, "timeout": { "type": "MANUAL" }, "authType": { "type": "MANUAL" }, "body_type": { "type": "MANUAL" }, "use_proxy": { "type": "MANUAL" }, "authFields": { "type": "MANUAL" }, "failureMode": { "type": "MANUAL" }, "queryParams": { "type": "MANUAL" }, "proxy_settings": { "type": "MANUAL" }, "followRedirects": { "type": "MANUAL" }, "response_is_binary": { "type": "MANUAL" } }, "errorHandlingOptions": { "retryOnFailure": { "value": true }, "continueOnFailure": { "value": false } } }, "displayName": "Alert to ntfy sink" }, null ], "settings": { "branches": [ { "branchName": "Alert", "branchType": "CONDITION", "conditions": [ [ { "operator": "BOOLEAN_IS_TRUE", "firstValue": "{{step_5['output'].hasAlert}}" } ] ] }, { "branchName": "Otherwise", "branchType": "FALLBACK" } ], "executionType": "EXECUTE_FIRST_MATCH", "propertySettings": {} }, "displayName": "Alert needed?" }, "displayName": "Store new state" }, "displayName": "Evaluate state" }, "displayName": "Load state" }, "displayName": "Call checker (TLS)" } }, "displayName": "Target list (domains.yaml stand-in)" }, "type": "PIECE_TRIGGER", "settings": { "propertySettings": { "minutes": { "type": "MANUAL" } }, "pieceName": "@activepieces/piece-schedule", "pieceVersion": "0.1.22", "triggerName": "every_x_minutes", "input": { "minutes": 1 } } } }