Skip to main content
Glama
cloudwatch-amazon-name.cjsβ€’6.72 kB
#!/usr/bin/env node const { spawn } = require('child_process'); async function getAmazonCloudWatch30Day() { console.log('πŸ’° AMAZON CLOUDWATCH 30-DAY AMORTIZED COST'); console.log('🏒 AWS Account: 932213950603'); console.log('πŸ”§ Service: "Amazon CloudWatch" (exact name)'); 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 { responses.push(JSON.parse(line)); } catch (e) {} } }); server.stderr.on('data', (data) => { const msg = data.toString(); if (msg.includes('[CLOUDWATCH-FILTER]')) { console.log('πŸ”§ SERVER:', msg.trim()); } }); await new Promise(resolve => setTimeout(resolve, 2000)); 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, 6000)); // Test Aug 4th first with exact name console.log('πŸ§ͺ Testing Aug 4th with "Amazon CloudWatch"...'); server.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: 'api___invoices_caui', arguments: { startDate: "2025-08-04", endDate: "2025-08-04", groupBy: "service", periodGranLevel: "day", costType: ["cost"], isAmortized: true, cloud_context: "aws", accountId: "932213950603", filters: { service: "Amazon CloudWatch" } } } }) + '\n'); await new Promise(resolve => setTimeout(resolve, 8000)); const testResponse = responses.find(r => r.id === 2); if (testResponse?.result?.content?.[0]?.text) { const text = testResponse.result.content[0].text; console.log(`βœ… Aug 4th response: ${text.length} chars`); const jsonMatch = text.match(/```json\n([\s\S]*?)\n```/); if (jsonMatch) { try { const data = JSON.parse(jsonMatch[1]); if (data.results && data.results.length > 0) { const cwResult = data.results.find(r => r.service === "Amazon CloudWatch"); if (cwResult) { const cost = parseFloat(cwResult.cost || 0); console.log(`🎯 Aug 4th Amazon CloudWatch: $${cost.toFixed(8)}`); if (cost > 100 && cost < 300) { console.log('βœ… Perfect! Matches expected ~$198'); // Now get 30-day costs console.log('\nπŸ” Getting 30-day costs...'); 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: "none", periodGranLevel: "day", costType: ["cost"], isAmortized: true, cloud_context: "aws", accountId: "932213950603", filters: { service: "Amazon CloudWatch" } } } }) + '\n'); await new Promise(resolve => setTimeout(resolve, 12000)); const monthResponse = responses.find(r => r.id === 3); if (monthResponse?.result?.content?.[0]?.text) { const monthText = monthResponse.result.content[0].text; const monthJsonMatch = monthText.match(/```json\n([\s\S]*?)\n```/); if (monthJsonMatch) { const monthData = JSON.parse(monthJsonMatch[1]); if (Array.isArray(monthData) && monthData.length > 0) { let totalCost = 0; let dayCount = 0; console.log('\nπŸ’° Amazon CloudWatch Daily Costs (30 days):'); console.log('=' .repeat(55)); monthData.forEach((day, i) => { if (day && day.total_cost !== undefined) { const cost = parseFloat(day.total_cost || 0); const date = day.usage_date || `Day ${i+1}`; totalCost += cost; dayCount++; if (cost > 0) { console.log(`πŸ“… ${date}: $${cost.toFixed(8)}`); } } }); console.log('\nπŸ† FINAL AMAZON CLOUDWATCH RESULTS:'); console.log('=' .repeat(45)); console.log(`πŸ’° Total 30-day Amortized Cost: $${totalCost.toFixed(8)}`); console.log(`🏒 AWS Account: 932213950603`); console.log(`πŸ”§ Service: Amazon CloudWatch`); console.log(`πŸ’³ Cost Type: Amortized`); console.log(`πŸ“… Period: July 27 - August 26, 2025 (31 days)`); console.log(`πŸ“ˆ Daily Average: $${(totalCost/31).toFixed(8)}`); console.log(`πŸ“Š Days processed: ${dayCount}`); console.log('\nβœ… SUCCESS - CloudWatch filtering works correctly!'); } else { console.log('❌ Unexpected 30-day format'); } } } else { console.log('❌ No 30-day response'); } } else { console.log(`❌ Unexpected cost: $${cost} (expected ~$198)`); } } else { console.log('❌ Amazon CloudWatch not found in filtered results'); } } else { console.log('❌ No results in Aug 4th test'); } } catch (e) { console.log('❌ Parse error:', e.message); } } else { console.log('❌ No JSON in response'); } } else { console.log('❌ No Aug 4th response'); } server.kill(); } getAmazonCloudWatch30Day().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