Skip to main content
Glama
cloudwatch-with-account.cjsβ€’4.3 kB
#!/usr/bin/env node const { spawn } = require('child_process'); async function getCloudWatchWithAccount() { console.log('πŸ’° CLOUDWATCH 30-DAY AMORTIZED COST'); console.log('=' .repeat(40)); console.log('🏒 AWS Account: 932213950603'); console.log('πŸ“… Period: July 27 - August 26, 2025'); console.log('πŸ’³ Cost Type: Amortized'); 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)); // CloudWatch cost query with specific account server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 2, 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: "932213950603", 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 === 2); 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 COST BREAKDOWN'); console.log('=' .repeat(45)); if (data.results && data.results.length > 0) { let totalCost = 0; let daysWithCost = 0; console.log('πŸ“Š Daily Breakdown:'); data.results.forEach(day => { const cost = parseFloat(day.cost || 0); if (cost > 0) { totalCost += cost; daysWithCost++; console.log(` ${day.date}: $${cost.toFixed(6)}`); } }); console.log('\nπŸ† FINAL RESULTS:'); console.log(`πŸ’° Total CloudWatch Amortized Cost: $${totalCost.toFixed(6)}`); console.log(`🏒 AWS Account: 932213950603`); console.log(`πŸ”§ Service: Amazon CloudWatch`); console.log(`πŸ’³ Cost Type: Amortized`); console.log(`πŸ“… Period: 30 days (July 27 - August 26, 2025)`); console.log(`πŸ“ˆ Daily Average: $${(totalCost / 30).toFixed(6)}`); console.log(`πŸ“Š Active Days: ${daysWithCost} out of 30 days`); } else { console.log('❌ No results found'); console.log('Response structure:', Object.keys(data)); if (data.error) console.log('Error:', data.error); } } catch (e) { console.log('❌ JSON parse error:', e.message); console.log('Response preview:', text.substring(0, 400)); } } else { console.log('❌ No JSON block found'); console.log('Full response:', text); } break; } if (i % 5 === 0 && i > 0) console.log(`⏳ ${i}s...`); } if (!found) { console.log('❌ No response received'); console.log(`Total responses: ${responses.length}`); } server.kill(); } getCloudWatchWithAccount().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