#!/usr/bin/env node
const { spawn } = require('child_process');
async function findCloudWatchService() {
console.log('🔍 FINDING EXACT 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));
// Get ALL services for August 4th to find 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"
// NO FILTER - get all services
}
}
}) + '\n');
console.log('🔍 Getting all services for Aug 4th to find CloudWatch...');
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]);
console.log('\n🔧 ALL SERVICES ON AUG 4TH:');
if (data.results && data.results.length > 0) {
const cloudwatchServices = [];
let totalCost = 0;
data.results.forEach(result => {
const service = result.service || result.service_name || 'Unknown';
const cost = parseFloat(result.cost || result.total_cost || 0);
totalCost += cost;
// Look for CloudWatch-related services
if (service.toLowerCase().includes('cloudwatch') ||
service.toLowerCase().includes('watch') ||
service.toLowerCase().includes('monitor')) {
cloudwatchServices.push({ service, cost });
console.log(`🎯 FOUND: "${service}" - $${cost.toFixed(10)}`);
}
});
console.log(`\n📊 Total account cost Aug 4th: $${totalCost.toFixed(2)}`);
console.log(`📊 Total services: ${data.results.length}`);
if (cloudwatchServices.length > 0) {
console.log(`\n✅ CloudWatch services found: ${cloudwatchServices.length}`);
cloudwatchServices.forEach(cw => {
console.log(` "${cw.service}": $${cw.cost.toFixed(10)}`);
});
// Test with the exact service name
const exactService = cloudwatchServices[0].service;
console.log(`\n🧪 Testing with exact service name: "${exactService}"`);
} else {
console.log('\n❌ No CloudWatch services found');
console.log('\nAll service names (first 20):');
data.results.slice(0, 20).forEach(result => {
const service = result.service || result.service_name || 'Unknown';
const cost = parseFloat(result.cost || result.total_cost || 0);
console.log(` "${service}" - $${cost.toFixed(2)}`);
});
}
}
} catch (e) {
console.log('❌ Parse error:', e.message);
}
}
break;
}
if (i % 5 === 0 && i > 0) console.log(`⏳ ${i}s...`);
}
server.kill();
}
findCloudWatchService().catch(console.error);