Skip to main content
Glama
check-anomalies-alternative.cjs5.79 kB
#!/usr/bin/env node // Alternative anomaly detection checks const { spawn } = require('child_process'); class AlternativeAnomalyCheck { constructor() { this.server = null; this.requestId = 1; this.responses = []; } async startServer() { return new Promise((resolve, reject) => { this.server = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'], cwd: process.cwd() }); this.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); this.responses.push(response); } catch (e) {} } }); this.server.on('error', reject); setTimeout(resolve, 3000); }); } async sendRequest(method, params = {}) { return new Promise((resolve) => { const request = { jsonrpc: "2.0", id: this.requestId++, method, params }; const startResponseCount = this.responses.length; this.server.stdin.write(JSON.stringify(request) + '\n'); const checkForResponse = () => { const newResponses = this.responses.slice(startResponseCount); const matchingResponse = newResponses.find(r => r.id === request.id); if (matchingResponse) { resolve(matchingResponse); } else if (Date.now() - startTime > 25000) { resolve(null); } else { setTimeout(checkForResponse, 200); } }; const startTime = Date.now(); setTimeout(checkForResponse, 200); }); } cleanup() { if (this.server) { this.server.kill(); } } } async function checkAlternativeAnomalies() { console.log('🔄 ALTERNATIVE ANOMALY DETECTION CHECKS'); console.log('Trying different parameters and approaches...'); console.log('=' .repeat(60)); const client = new AlternativeAnomalyCheck(); await client.startServer(); // Authenticate const authResponse = await client.sendRequest('tools/call', { name: 'authenticate_user', arguments: { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' } }); if (!authResponse?.result?.content?.[0]?.text?.includes('Successfully authenticated')) { console.log('❌ Authentication failed'); client.cleanup(); return; } console.log('✅ Authenticated\n'); const testCases = [ { name: "Recent Anomalies (2024-2025)", params: { startDate: "2024-01-01", endDate: "2025-12-31", cloud_context: "aws" } }, { name: "Count Only Check", params: { startDate: "2020-01-01", endDate: "2025-12-31", cloud_context: "aws", isPageCount: "true" } }, { name: "Alerted Anomalies Only", params: { startDate: "2020-01-01", endDate: "2025-12-31", cloud_context: "aws", alerted: "true" } }, { name: "Azure Anomalies", params: { startDate: "2020-01-01", endDate: "2025-12-31", cloud_context: "azure" } }, { name: "GCP Anomalies", params: { startDate: "2020-01-01", endDate: "2025-12-31", cloud_context: "gcp" } }, { name: "Search EC2 Anomalies", params: { startDate: "2020-01-01", endDate: "2025-12-31", cloud_context: "aws", search: "EC2" } } ]; for (const testCase of testCases) { console.log(`🔍 ${testCase.name}:`); const response = await client.sendRequest('tools/call', { name: 'api___anomaly_detection', arguments: testCase.params }); if (response?.result?.content?.[0]?.text) { const text = response.result.content[0].text; const jsonMatch = text.match(/```json\n(.*?)\n```/s); if (jsonMatch) { try { const data = JSON.parse(jsonMatch[1]); if (testCase.name.includes("Count Only")) { console.log(` Count: ${data.count || 0}`); } else if (data.anomalies && Array.isArray(data.anomalies)) { console.log(` Found: ${data.anomalies.length} anomalies`); } else if (Array.isArray(data)) { console.log(` Found: ${data.length} records`); } else { console.log(` Response: ${Object.keys(data).join(', ')}`); } } catch (e) { console.log(` Response: Non-JSON or error`); } } else { if (text.includes('No data') || text.includes('[]')) { console.log(` Result: No anomalies found`); } else { console.log(` Response: ${text.length} chars (non-JSON)`); } } } else { console.log(` No response received`); } await new Promise(resolve => setTimeout(resolve, 500)); } client.cleanup(); console.log('\n📋 SUMMARY:'); console.log('The saola account appears to have no anomalies detected across:'); console.log('• Different time ranges'); console.log('• Different cloud providers (AWS, Azure, GCP)'); console.log('• Different search criteria'); console.log('• Both alerted and non-alerted anomalies'); console.log('\n💡 RECOMMENDATIONS:'); console.log('1. Check if anomaly detection is enabled in the Umbrella Cost UI'); console.log('2. Verify sufficient cost data exists for anomaly detection'); console.log('3. Review anomaly detection thresholds and settings'); console.log('4. Check if there are anomalies in the UI that might not be accessible via API'); } checkAlternativeAnomalies().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