Skip to main content
Glama
cloudwatch-amortized-30days.cjsβ€’5.09 kB
#!/usr/bin/env node const { spawn } = require('child_process'); async function getCloudWatchAmortized30Days() { console.log('πŸ’° CLOUDWATCH 30-DAY AMORTIZED COST'); console.log('=' .repeat(40)); console.log('πŸ“… Period: July 27 - August 26, 2025 (30 days)'); console.log('πŸ’³ Cost Type: Amortized'); console.log('πŸ”§ Service: Amazon CloudWatch'); const server = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'], env: { ...process.env, UMBRELLA_API_BASE_URL: 'https://api-front.umbrellacost.io/api/v1' } }); const responses = []; server.stdout.on('data', (data) => { const lines = data.toString().split('\n').filter(line => line.trim()); for (const line of lines) { try { const response = JSON.parse(line); responses.push(response); } catch (e) {} } }); await new Promise(resolve => setTimeout(resolve, 2000)); // Auth server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: 'authenticate_user', arguments: { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' } } }) + '\n'); console.log('πŸ” Authenticating...'); await new Promise(resolve => setTimeout(resolve, 5000)); // Get account info first server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: 'api__user_management_accounts', arguments: {} } }) + '\n'); await new Promise(resolve => setTimeout(resolve, 3000)); const accountsResponse = responses.find(r => r.id === 2); let accountId = null; if (accountsResponse?.result?.content?.[0]?.text) { const text = accountsResponse.result.content[0].text; const jsonMatch = text.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { try { const data = JSON.parse(jsonMatch[1]); if (data.accounts && data.accounts.length > 0) { accountId = data.accounts[0].linkedaccid; console.log(`🏒 Using account: ${accountId}`); } } catch (e) {} } } if (!accountId) { console.log('❌ Could not get account ID'); server.kill(); return; } // CloudWatch amortized cost query server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 3, method: "tools/call", params: { name: 'api__invoices_caui', arguments: { startDate: "2025-07-27", endDate: "2025-08-26", groupBy: "service", periodGranLevel: "day", costType: ["cost"], isAmortized: "true", cloud_context: "aws", accountId: accountId, filters: { service: "Amazon CloudWatch" } } } }) + '\n'); console.log('πŸ” Getting CloudWatch amortized costs...'); let found = false; for (let i = 0; i < 25 && !found; i++) { await new Promise(resolve => setTimeout(resolve, 1000)); const response = responses.find(r => r.id === 3); if (response?.result?.content?.[0]?.text) { found = true; const text = response.result.content[0].text; const jsonMatch = text.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { try { const data = JSON.parse(jsonMatch[1]); console.log('\nπŸ’° CLOUDWATCH AMORTIZED COSTS (30 DAYS)'); console.log('=' .repeat(45)); if (data.results && data.results.length > 0) { let totalCost = 0; data.results.forEach((day, i) => { const date = day.date; const cost = parseFloat(day.cost || 0); totalCost += cost; if (cost > 0) { console.log(`πŸ“… ${date}: $${cost.toFixed(4)}`); } }); console.log(`\nπŸ† TOTAL CLOUDWATCH AMORTIZED COST: $${totalCost.toFixed(4)}`); console.log(`πŸ“Š Service: Amazon CloudWatch`); console.log(`πŸ“… Period: 30 days (July 27 - August 26, 2025)`); console.log(`πŸ’³ Cost Type: Amortized`); console.log(`πŸ“ˆ Daily Average: $${(totalCost / 30).toFixed(4)}`); if (totalCost > 0) { console.log('\nβœ… CloudWatch amortized cost calculation successful'); } else { console.log('\n⚠️ Zero cost detected - may indicate no CloudWatch usage in this period'); } } else { console.log('❌ No cost data found'); console.log('Response keys:', Object.keys(data)); } } catch (e) { console.log('❌ JSON parsing error:', e.message); } } else { console.log('❌ No JSON found in response'); console.log('Response preview:', text.substring(0, 200)); } break; } if (i % 10 === 0 && i > 0) console.log(`⏳ ${i}s...`); } if (!found) { console.log('❌ No response within 25 seconds'); } server.kill(); } getCloudWatchAmortized30Days().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server