#!/usr/bin/env node
const { spawn } = require('child_process');
async function checkCloudWatchService() {
console.log('🔍 CHECKING CLOUDWATCH SERVICE 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) {}
}
});
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');
await new Promise(resolve => setTimeout(resolve, 6000));
// Try getting all costs for this account to see what services exist
server.stdin.write(JSON.stringify({
jsonrpc: "2.0", id: 2, method: "tools/call",
params: {
name: 'api___invoices_caui',
arguments: {
startDate: "2025-08-01",
endDate: "2025-08-26",
groupBy: "service",
periodGranLevel: "month",
costType: ["cost"],
isAmortized: "true",
cloud_context: "aws",
accountId: "932213950603"
}
}
}) + '\n');
console.log('🔍 Getting all services with costs...');
for (let i = 0; i < 20; i++) {
await new Promise(resolve => setTimeout(resolve, 1000));
const response = responses.find(r => r.id === 2);
if (response?.result?.content?.[0]?.text) {
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]);
if (data.results && data.results.length > 0) {
console.log('\n🔧 Available Services with Costs:');
const services = new Set();
data.results.forEach(item => {
if (item.service && parseFloat(item.cost || 0) > 0) {
services.add(item.service);
}
});
const serviceList = Array.from(services).sort();
serviceList.forEach(service => {
console.log(` • ${service}`);
if (service.toLowerCase().includes('cloudwatch') ||
service.toLowerCase().includes('monitor') ||
service.toLowerCase().includes('watch')) {
console.log(` 👆 THIS LOOKS LIKE CLOUDWATCH!`);
}
});
console.log(`\n📊 Total services with costs: ${serviceList.length}`);
// Now try CloudWatch specifically if we found the right name
const cloudwatchService = serviceList.find(s =>
s.toLowerCase().includes('cloudwatch') ||
s.toLowerCase().includes('amazon cloudwatch')
);
if (cloudwatchService) {
console.log(`\n🎯 Found CloudWatch service: "${cloudwatchService}"`);
console.log('Now getting CloudWatch 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",
service: cloudwatchService
}
}
}) + '\n');
// Wait for CloudWatch specific results
for (let j = 0; j < 15; j++) {
await new Promise(resolve => setTimeout(resolve, 1000));
const cwResponse = responses.find(r => r.id === 3);
if (cwResponse?.result?.content?.[0]?.text) {
const cwText = cwResponse.result.content[0].text;
const cwJsonMatch = cwText.match(/```json\n([\s\S]*?)\n```/);
if (cwJsonMatch) {
const cwData = JSON.parse(cwJsonMatch[1]);
if (cwData.results && cwData.results.length > 0) {
let totalCost = 0;
cwData.results.forEach(day => {
const cost = parseFloat(day.cost || 0);
totalCost += cost;
});
console.log(`\n🏆 CLOUDWATCH 30-DAY AMORTIZED COST: $${totalCost.toFixed(8)}`);
console.log(`🔧 Service: ${cloudwatchService}`);
console.log(`🏢 Account: 932213950603`);
console.log(`📅 Period: July 27 - August 26, 2025`);
}
}
break;
}
}
} else {
console.log('\n❌ CloudWatch service not found in cost data');
console.log('This might mean CloudWatch has $0.00 costs for this period');
}
}
} catch (e) {
console.log('❌ Parse error:', e.message);
}
}
break;
}
if (i % 5 === 0 && i > 0) console.log(`⏳ ${i}s...`);
}
server.kill();
}
checkCloudWatchService().catch(console.error);