@friggframework/devtools 2.0.0-next.3 → 2.0.0-next.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/frigg-cli/.eslintrc.js +141 -0
- package/frigg-cli/__tests__/jest.config.js +102 -0
- package/frigg-cli/__tests__/unit/commands/build.test.js +483 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +418 -0
- package/frigg-cli/__tests__/unit/commands/ui.test.js +592 -0
- package/frigg-cli/__tests__/utils/command-tester.js +170 -0
- package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
- package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
- package/frigg-cli/__tests__/utils/test-setup.js +286 -0
- package/frigg-cli/build-command/index.js +54 -0
- package/frigg-cli/deploy-command/index.js +36 -0
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +312 -0
- package/frigg-cli/generate-command/azure-generator.js +43 -0
- package/frigg-cli/generate-command/gcp-generator.js +47 -0
- package/frigg-cli/generate-command/index.js +332 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/generate-iam-command.js +115 -0
- package/frigg-cli/index.js +47 -1
- package/frigg-cli/index.test.js +1 -4
- package/frigg-cli/init-command/backend-first-handler.js +756 -0
- package/frigg-cli/init-command/index.js +93 -0
- package/frigg-cli/init-command/template-handler.js +143 -0
- package/frigg-cli/install-command/index.js +1 -4
- package/frigg-cli/package.json +51 -0
- package/frigg-cli/start-command/index.js +24 -4
- package/frigg-cli/test/init-command.test.js +180 -0
- package/frigg-cli/test/npm-registry.test.js +319 -0
- package/frigg-cli/ui-command/index.js +154 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +16 -17
- package/frigg-cli/utils/npm-registry.js +167 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +245 -0
- package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +596 -0
- package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +268 -0
- package/infrastructure/GENERATE-IAM-DOCS.md +253 -0
- package/infrastructure/IAM-POLICY-TEMPLATES.md +176 -0
- package/infrastructure/README-TESTING.md +332 -0
- package/infrastructure/README.md +421 -0
- package/infrastructure/WEBSOCKET-CONFIGURATION.md +105 -0
- package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
- package/infrastructure/__tests__/helpers/test-utils.js +277 -0
- package/infrastructure/aws-discovery.js +568 -0
- package/infrastructure/aws-discovery.test.js +373 -0
- package/infrastructure/build-time-discovery.js +206 -0
- package/infrastructure/build-time-discovery.test.js +375 -0
- package/infrastructure/create-frigg-infrastructure.js +3 -5
- package/infrastructure/frigg-deployment-iam-stack.yaml +379 -0
- package/infrastructure/iam-generator.js +687 -0
- package/infrastructure/iam-generator.test.js +169 -0
- package/infrastructure/iam-policy-basic.json +212 -0
- package/infrastructure/iam-policy-full.json +282 -0
- package/infrastructure/integration.test.js +383 -0
- package/infrastructure/run-discovery.js +110 -0
- package/infrastructure/serverless-template.js +923 -113
- package/infrastructure/serverless-template.test.js +541 -0
- package/management-ui/.eslintrc.js +22 -0
- package/management-ui/README.md +203 -0
- package/management-ui/components.json +21 -0
- package/management-ui/docs/phase2-integration-guide.md +320 -0
- package/management-ui/index.html +13 -0
- package/management-ui/package-lock.json +16517 -0
- package/management-ui/package.json +76 -0
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
- package/management-ui/postcss.config.js +6 -0
- package/management-ui/server/api/backend.js +256 -0
- package/management-ui/server/api/cli.js +315 -0
- package/management-ui/server/api/codegen.js +663 -0
- package/management-ui/server/api/connections.js +857 -0
- package/management-ui/server/api/discovery.js +185 -0
- package/management-ui/server/api/environment/index.js +1 -0
- package/management-ui/server/api/environment/router.js +378 -0
- package/management-ui/server/api/environment.js +328 -0
- package/management-ui/server/api/integrations.js +876 -0
- package/management-ui/server/api/logs.js +248 -0
- package/management-ui/server/api/monitoring.js +282 -0
- package/management-ui/server/api/open-ide.js +31 -0
- package/management-ui/server/api/project.js +1029 -0
- package/management-ui/server/api/users/sessions.js +371 -0
- package/management-ui/server/api/users/simulation.js +254 -0
- package/management-ui/server/api/users.js +362 -0
- package/management-ui/server/api-contract.md +275 -0
- package/management-ui/server/index.js +873 -0
- package/management-ui/server/middleware/errorHandler.js +93 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +346 -0
- package/management-ui/server/services/aws-monitor.js +413 -0
- package/management-ui/server/services/npm-registry.js +347 -0
- package/management-ui/server/services/template-engine.js +538 -0
- package/management-ui/server/utils/cliIntegration.js +220 -0
- package/management-ui/server/utils/environment/auditLogger.js +471 -0
- package/management-ui/server/utils/environment/awsParameterStore.js +264 -0
- package/management-ui/server/utils/environment/encryption.js +278 -0
- package/management-ui/server/utils/environment/envFileManager.js +286 -0
- package/management-ui/server/utils/import-commonjs.js +28 -0
- package/management-ui/server/utils/response.js +83 -0
- package/management-ui/server/websocket/handler.js +325 -0
- package/management-ui/src/App.jsx +109 -0
- package/management-ui/src/assets/FriggLogo.svg +1 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +70 -0
- package/management-ui/src/components/Card.jsx +97 -0
- package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
- package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
- package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
- package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
- package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
- package/management-ui/src/components/ErrorBoundary.jsx +73 -0
- package/management-ui/src/components/IntegrationCard.jsx +481 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +336 -0
- package/management-ui/src/components/Layout.jsx +716 -0
- package/management-ui/src/components/LoadingSpinner.jsx +113 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +350 -0
- package/management-ui/src/components/StatusBadge.jsx +208 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
- package/management-ui/src/components/UserSimulation.jsx +327 -0
- package/management-ui/src/components/Welcome.jsx +434 -0
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
- package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
- package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
- package/management-ui/src/components/codegen/index.js +10 -0
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
- package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
- package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
- package/management-ui/src/components/connections/index.js +5 -0
- package/management-ui/src/components/index.js +21 -0
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
- package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
- package/management-ui/src/components/monitoring/index.js +6 -0
- package/management-ui/src/components/monitoring/monitoring.css +218 -0
- package/management-ui/src/components/theme-provider.jsx +52 -0
- package/management-ui/src/components/theme-toggle.jsx +39 -0
- package/management-ui/src/components/ui/badge.tsx +36 -0
- package/management-ui/src/components/ui/button.test.jsx +56 -0
- package/management-ui/src/components/ui/button.tsx +57 -0
- package/management-ui/src/components/ui/card.tsx +76 -0
- package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
- package/management-ui/src/components/ui/select.tsx +157 -0
- package/management-ui/src/components/ui/skeleton.jsx +15 -0
- package/management-ui/src/hooks/useFrigg.jsx +601 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +193 -0
- package/management-ui/src/lib/utils.ts +6 -0
- package/management-ui/src/main.jsx +10 -0
- package/management-ui/src/pages/CodeGeneration.jsx +14 -0
- package/management-ui/src/pages/Connections.jsx +252 -0
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
- package/management-ui/src/pages/Dashboard.jsx +311 -0
- package/management-ui/src/pages/Environment.jsx +314 -0
- package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
- package/management-ui/src/pages/IntegrationTest.jsx +742 -0
- package/management-ui/src/pages/Integrations.jsx +253 -0
- package/management-ui/src/pages/Monitoring.jsx +17 -0
- package/management-ui/src/pages/Simulation.jsx +155 -0
- package/management-ui/src/pages/Users.jsx +492 -0
- package/management-ui/src/services/api.js +41 -0
- package/management-ui/src/services/apiModuleService.js +193 -0
- package/management-ui/src/services/websocket-handlers.js +120 -0
- package/management-ui/src/test/api/project.test.js +273 -0
- package/management-ui/src/test/components/Welcome.test.jsx +378 -0
- package/management-ui/src/test/mocks/server.js +178 -0
- package/management-ui/src/test/setup.js +61 -0
- package/management-ui/src/test/utils/test-utils.jsx +134 -0
- package/management-ui/src/utils/repository.js +98 -0
- package/management-ui/src/utils/repository.test.js +118 -0
- package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
- package/management-ui/tailwind.config.js +63 -0
- package/management-ui/tsconfig.json +37 -0
- package/management-ui/tsconfig.node.json +10 -0
- package/management-ui/vite.config.js +26 -0
- package/management-ui/vitest.config.js +38 -0
- package/package.json +16 -9
- package/infrastructure/app-handler-helpers.js +0 -57
- package/infrastructure/backend-utils.js +0 -90
- package/infrastructure/routers/auth.js +0 -26
- package/infrastructure/routers/integration-defined-routers.js +0 -37
- package/infrastructure/routers/middleware/loadUser.js +0 -15
- package/infrastructure/routers/middleware/requireLoggedInUser.js +0 -12
- package/infrastructure/routers/user.js +0 -41
- package/infrastructure/routers/websocket.js +0 -55
- package/infrastructure/workers/integration-defined-workers.js +0 -24
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { Card } from '../Card'
|
|
3
|
+
import { Button } from '../Button'
|
|
4
|
+
import { StatusBadge } from '../StatusBadge'
|
|
5
|
+
import LoadingSpinner from '../LoadingSpinner'
|
|
6
|
+
import { useSocket } from '../../hooks/useSocket'
|
|
7
|
+
import LambdaMetrics from './LambdaMetrics'
|
|
8
|
+
import APIGatewayMetrics from './APIGatewayMetrics'
|
|
9
|
+
import SQSMetrics from './SQSMetrics'
|
|
10
|
+
import MetricsChart from './MetricsChart'
|
|
11
|
+
import './monitoring.css'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Production Monitoring Dashboard Component
|
|
15
|
+
* Displays real-time metrics from AWS CloudWatch for production Frigg instances
|
|
16
|
+
*/
|
|
17
|
+
function MonitoringDashboard() {
|
|
18
|
+
const [monitoringStatus, setMonitoringStatus] = useState({
|
|
19
|
+
initialized: false,
|
|
20
|
+
isMonitoring: false,
|
|
21
|
+
config: null
|
|
22
|
+
})
|
|
23
|
+
const [metrics, setMetrics] = useState(null)
|
|
24
|
+
const [loading, setLoading] = useState(false)
|
|
25
|
+
const [error, setError] = useState(null)
|
|
26
|
+
const [selectedView, setSelectedView] = useState('overview')
|
|
27
|
+
|
|
28
|
+
const { socket, connected } = useSocket()
|
|
29
|
+
|
|
30
|
+
// Initialize monitoring on component mount
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
checkMonitoringStatus()
|
|
33
|
+
}, [])
|
|
34
|
+
|
|
35
|
+
// Subscribe to real-time metrics via WebSocket
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!socket || !connected) return
|
|
38
|
+
|
|
39
|
+
const handleMetrics = (data) => {
|
|
40
|
+
setMetrics(data)
|
|
41
|
+
setError(null)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const handleError = (error) => {
|
|
45
|
+
setError(error.message || 'Monitoring error occurred')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Subscribe to monitoring events
|
|
49
|
+
socket.emit('subscribe', { topics: ['monitoring:metrics', 'monitoring:error'] })
|
|
50
|
+
|
|
51
|
+
socket.on('broadcast', (message) => {
|
|
52
|
+
if (message.topic === 'monitoring:metrics') {
|
|
53
|
+
handleMetrics(message.data)
|
|
54
|
+
} else if (message.topic === 'monitoring:error') {
|
|
55
|
+
handleError(message.data)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
return () => {
|
|
60
|
+
socket.emit('unsubscribe', { topics: ['monitoring:metrics', 'monitoring:error'] })
|
|
61
|
+
socket.off('broadcast')
|
|
62
|
+
}
|
|
63
|
+
}, [socket, connected])
|
|
64
|
+
|
|
65
|
+
const checkMonitoringStatus = async () => {
|
|
66
|
+
try {
|
|
67
|
+
const response = await fetch('/api/monitoring/status')
|
|
68
|
+
const data = await response.json()
|
|
69
|
+
setMonitoringStatus(data)
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error('Failed to check monitoring status:', err)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const initializeMonitoring = async () => {
|
|
76
|
+
setLoading(true)
|
|
77
|
+
setError(null)
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
// Initialize with default configuration
|
|
81
|
+
const initResponse = await fetch('/api/monitoring/init', {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
headers: { 'Content-Type': 'application/json' },
|
|
84
|
+
body: JSON.stringify({
|
|
85
|
+
collectionInterval: 60000 // 1 minute
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
if (!initResponse.ok) {
|
|
90
|
+
throw new Error('Failed to initialize monitoring')
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Start monitoring
|
|
94
|
+
const startResponse = await fetch('/api/monitoring/start', {
|
|
95
|
+
method: 'POST'
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (!startResponse.ok) {
|
|
99
|
+
throw new Error('Failed to start monitoring')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await checkMonitoringStatus()
|
|
103
|
+
|
|
104
|
+
// Force initial collection
|
|
105
|
+
await collectMetricsNow()
|
|
106
|
+
} catch (err) {
|
|
107
|
+
setError(err.message)
|
|
108
|
+
} finally {
|
|
109
|
+
setLoading(false)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const stopMonitoring = async () => {
|
|
114
|
+
setLoading(true)
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const response = await fetch('/api/monitoring/stop', {
|
|
118
|
+
method: 'POST'
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
throw new Error('Failed to stop monitoring')
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
await checkMonitoringStatus()
|
|
126
|
+
setMetrics(null)
|
|
127
|
+
} catch (err) {
|
|
128
|
+
setError(err.message)
|
|
129
|
+
} finally {
|
|
130
|
+
setLoading(false)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const collectMetricsNow = async () => {
|
|
135
|
+
setLoading(true)
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
const response = await fetch('/api/monitoring/metrics/collect', {
|
|
139
|
+
method: 'POST'
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
throw new Error('Failed to collect metrics')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const result = await response.json()
|
|
147
|
+
if (result.success) {
|
|
148
|
+
setMetrics(result.data)
|
|
149
|
+
}
|
|
150
|
+
} catch (err) {
|
|
151
|
+
setError(err.message)
|
|
152
|
+
} finally {
|
|
153
|
+
setLoading(false)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const renderOverview = () => {
|
|
158
|
+
if (!metrics) {
|
|
159
|
+
return (
|
|
160
|
+
<div className="text-center py-8 text-gray-500">
|
|
161
|
+
No metrics available. Start monitoring to see data.
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const { lambda, apiGateway, sqs } = metrics
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
170
|
+
{/* Lambda Overview */}
|
|
171
|
+
<Card>
|
|
172
|
+
<h3 className="text-lg font-semibold mb-2">Lambda Functions</h3>
|
|
173
|
+
<div className="space-y-2">
|
|
174
|
+
<div className="flex justify-between">
|
|
175
|
+
<span>Total Functions:</span>
|
|
176
|
+
<span className="font-mono">{lambda.totalFunctions || 0}</span>
|
|
177
|
+
</div>
|
|
178
|
+
{lambda.functions && lambda.functions.length > 0 && (
|
|
179
|
+
<>
|
|
180
|
+
<div className="flex justify-between">
|
|
181
|
+
<span>Total Invocations:</span>
|
|
182
|
+
<span className="font-mono">
|
|
183
|
+
{lambda.functions.reduce((sum, fn) =>
|
|
184
|
+
sum + (fn.metrics?.invocations || 0), 0
|
|
185
|
+
)}
|
|
186
|
+
</span>
|
|
187
|
+
</div>
|
|
188
|
+
<div className="flex justify-between">
|
|
189
|
+
<span>Total Errors:</span>
|
|
190
|
+
<span className="font-mono text-red-600">
|
|
191
|
+
{lambda.functions.reduce((sum, fn) =>
|
|
192
|
+
sum + (fn.metrics?.errors || 0), 0
|
|
193
|
+
)}
|
|
194
|
+
</span>
|
|
195
|
+
</div>
|
|
196
|
+
</>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
</Card>
|
|
200
|
+
|
|
201
|
+
{/* API Gateway Overview */}
|
|
202
|
+
<Card>
|
|
203
|
+
<h3 className="text-lg font-semibold mb-2">API Gateway</h3>
|
|
204
|
+
<div className="space-y-2">
|
|
205
|
+
<div className="flex justify-between">
|
|
206
|
+
<span>Total APIs:</span>
|
|
207
|
+
<span className="font-mono">{apiGateway.totalApis || 0}</span>
|
|
208
|
+
</div>
|
|
209
|
+
{apiGateway.apis && apiGateway.apis.length > 0 && (
|
|
210
|
+
<>
|
|
211
|
+
<div className="flex justify-between">
|
|
212
|
+
<span>Total Requests:</span>
|
|
213
|
+
<span className="font-mono">
|
|
214
|
+
{apiGateway.apis.reduce((sum, api) =>
|
|
215
|
+
sum + (api.metrics?.count || 0), 0
|
|
216
|
+
)}
|
|
217
|
+
</span>
|
|
218
|
+
</div>
|
|
219
|
+
<div className="flex justify-between">
|
|
220
|
+
<span>Error Rate:</span>
|
|
221
|
+
<span className="font-mono">
|
|
222
|
+
{apiGateway.apis[0]?.metrics?.errorRate?.toFixed(2) || 0}%
|
|
223
|
+
</span>
|
|
224
|
+
</div>
|
|
225
|
+
</>
|
|
226
|
+
)}
|
|
227
|
+
</div>
|
|
228
|
+
</Card>
|
|
229
|
+
|
|
230
|
+
{/* SQS Overview */}
|
|
231
|
+
<Card>
|
|
232
|
+
<h3 className="text-lg font-semibold mb-2">SQS Queues</h3>
|
|
233
|
+
<div className="space-y-2">
|
|
234
|
+
<div className="flex justify-between">
|
|
235
|
+
<span>Total Queues:</span>
|
|
236
|
+
<span className="font-mono">{sqs.totalQueues || 0}</span>
|
|
237
|
+
</div>
|
|
238
|
+
{sqs.queues && sqs.queues.length > 0 && (
|
|
239
|
+
<>
|
|
240
|
+
<div className="flex justify-between">
|
|
241
|
+
<span>Messages Available:</span>
|
|
242
|
+
<span className="font-mono">
|
|
243
|
+
{sqs.queues.reduce((sum, queue) =>
|
|
244
|
+
sum + (queue.messagesAvailable || 0), 0
|
|
245
|
+
)}
|
|
246
|
+
</span>
|
|
247
|
+
</div>
|
|
248
|
+
<div className="flex justify-between">
|
|
249
|
+
<span>Messages In Flight:</span>
|
|
250
|
+
<span className="font-mono">
|
|
251
|
+
{sqs.queues.reduce((sum, queue) =>
|
|
252
|
+
sum + (queue.messagesInFlight || 0), 0
|
|
253
|
+
)}
|
|
254
|
+
</span>
|
|
255
|
+
</div>
|
|
256
|
+
</>
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
259
|
+
</Card>
|
|
260
|
+
</div>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<div className="monitoring-dashboard">
|
|
266
|
+
<div className="mb-6">
|
|
267
|
+
<h2 className="text-2xl font-bold mb-2">Production Monitoring</h2>
|
|
268
|
+
<p className="text-gray-600">
|
|
269
|
+
Monitor your production Frigg instances in real-time with AWS CloudWatch integration
|
|
270
|
+
</p>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
{/* Status Bar */}
|
|
274
|
+
<Card className="mb-6">
|
|
275
|
+
<div className="flex items-center justify-between">
|
|
276
|
+
<div className="flex items-center gap-4">
|
|
277
|
+
<StatusBadge
|
|
278
|
+
status={monitoringStatus.isMonitoring ? 'success' : 'inactive'}
|
|
279
|
+
text={monitoringStatus.isMonitoring ? 'Monitoring Active' : 'Monitoring Inactive'}
|
|
280
|
+
/>
|
|
281
|
+
{monitoringStatus.config && (
|
|
282
|
+
<div className="text-sm text-gray-600">
|
|
283
|
+
Region: <span className="font-mono">{monitoringStatus.config.region}</span> |
|
|
284
|
+
Stage: <span className="font-mono">{monitoringStatus.config.stage}</span> |
|
|
285
|
+
Service: <span className="font-mono">{monitoringStatus.config.serviceName}</span>
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
</div>
|
|
289
|
+
<div className="flex gap-2">
|
|
290
|
+
{!monitoringStatus.isMonitoring ? (
|
|
291
|
+
<Button
|
|
292
|
+
onClick={initializeMonitoring}
|
|
293
|
+
disabled={loading}
|
|
294
|
+
>
|
|
295
|
+
{loading ? <LoadingSpinner size="sm" /> : 'Start Monitoring'}
|
|
296
|
+
</Button>
|
|
297
|
+
) : (
|
|
298
|
+
<>
|
|
299
|
+
<Button
|
|
300
|
+
variant="secondary"
|
|
301
|
+
onClick={collectMetricsNow}
|
|
302
|
+
disabled={loading}
|
|
303
|
+
>
|
|
304
|
+
Refresh Now
|
|
305
|
+
</Button>
|
|
306
|
+
<Button
|
|
307
|
+
variant="secondary"
|
|
308
|
+
onClick={stopMonitoring}
|
|
309
|
+
disabled={loading}
|
|
310
|
+
>
|
|
311
|
+
Stop Monitoring
|
|
312
|
+
</Button>
|
|
313
|
+
</>
|
|
314
|
+
)}
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</Card>
|
|
318
|
+
|
|
319
|
+
{/* Error Display */}
|
|
320
|
+
{error && (
|
|
321
|
+
<Card className="mb-6 border-red-500 bg-red-50">
|
|
322
|
+
<div className="text-red-700">
|
|
323
|
+
<strong>Error:</strong> {error}
|
|
324
|
+
</div>
|
|
325
|
+
</Card>
|
|
326
|
+
)}
|
|
327
|
+
|
|
328
|
+
{/* Navigation Tabs */}
|
|
329
|
+
<div className="flex gap-2 mb-6">
|
|
330
|
+
<Button
|
|
331
|
+
variant={selectedView === 'overview' ? 'primary' : 'secondary'}
|
|
332
|
+
onClick={() => setSelectedView('overview')}
|
|
333
|
+
>
|
|
334
|
+
Overview
|
|
335
|
+
</Button>
|
|
336
|
+
<Button
|
|
337
|
+
variant={selectedView === 'lambda' ? 'primary' : 'secondary'}
|
|
338
|
+
onClick={() => setSelectedView('lambda')}
|
|
339
|
+
>
|
|
340
|
+
Lambda Functions
|
|
341
|
+
</Button>
|
|
342
|
+
<Button
|
|
343
|
+
variant={selectedView === 'apigateway' ? 'primary' : 'secondary'}
|
|
344
|
+
onClick={() => setSelectedView('apigateway')}
|
|
345
|
+
>
|
|
346
|
+
API Gateway
|
|
347
|
+
</Button>
|
|
348
|
+
<Button
|
|
349
|
+
variant={selectedView === 'sqs' ? 'primary' : 'secondary'}
|
|
350
|
+
onClick={() => setSelectedView('sqs')}
|
|
351
|
+
>
|
|
352
|
+
SQS Queues
|
|
353
|
+
</Button>
|
|
354
|
+
<Button
|
|
355
|
+
variant={selectedView === 'charts' ? 'primary' : 'secondary'}
|
|
356
|
+
onClick={() => setSelectedView('charts')}
|
|
357
|
+
>
|
|
358
|
+
Charts
|
|
359
|
+
</Button>
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
{/* Content Area */}
|
|
363
|
+
{loading && !metrics ? (
|
|
364
|
+
<Card>
|
|
365
|
+
<div className="flex items-center justify-center py-8">
|
|
366
|
+
<LoadingSpinner />
|
|
367
|
+
<span className="ml-2">Loading metrics...</span>
|
|
368
|
+
</div>
|
|
369
|
+
</Card>
|
|
370
|
+
) : (
|
|
371
|
+
<>
|
|
372
|
+
{selectedView === 'overview' && renderOverview()}
|
|
373
|
+
{selectedView === 'lambda' && <LambdaMetrics metrics={metrics?.lambda} />}
|
|
374
|
+
{selectedView === 'apigateway' && <APIGatewayMetrics metrics={metrics?.apiGateway} />}
|
|
375
|
+
{selectedView === 'sqs' && <SQSMetrics metrics={metrics?.sqs} />}
|
|
376
|
+
{selectedView === 'charts' && <MetricsChart metrics={metrics} />}
|
|
377
|
+
</>
|
|
378
|
+
)}
|
|
379
|
+
|
|
380
|
+
{/* Last Updated */}
|
|
381
|
+
{metrics && (
|
|
382
|
+
<div className="mt-4 text-sm text-gray-500 text-right">
|
|
383
|
+
Last updated: {new Date(metrics.timestamp).toLocaleString()}
|
|
384
|
+
{metrics.collectionDuration && (
|
|
385
|
+
<span> (collected in {metrics.collectionDuration}ms)</span>
|
|
386
|
+
)}
|
|
387
|
+
</div>
|
|
388
|
+
)}
|
|
389
|
+
</div>
|
|
390
|
+
)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export default MonitoringDashboard
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Card } from '../Card'
|
|
3
|
+
import { StatusBadge } from '../StatusBadge'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SQS Queue Metrics Component
|
|
7
|
+
* Displays detailed metrics for AWS SQS queues
|
|
8
|
+
*/
|
|
9
|
+
function SQSMetrics({ metrics }) {
|
|
10
|
+
if (!metrics || metrics.error) {
|
|
11
|
+
return (
|
|
12
|
+
<Card>
|
|
13
|
+
<div className="text-center py-8 text-gray-500">
|
|
14
|
+
{metrics?.error || 'No SQS metrics available'}
|
|
15
|
+
</div>
|
|
16
|
+
</Card>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { queues = [] } = metrics
|
|
21
|
+
|
|
22
|
+
const getQueueStatus = (queue) => {
|
|
23
|
+
if (queue.error) return 'error'
|
|
24
|
+
if (queue.messagesAvailable > 100) return 'warning'
|
|
25
|
+
if (queue.messagesInFlight > 0) return 'success'
|
|
26
|
+
return 'inactive'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const formatAge = (timestamp) => {
|
|
30
|
+
if (!timestamp) return 'Unknown'
|
|
31
|
+
const age = Date.now() - parseInt(timestamp) * 1000
|
|
32
|
+
const days = Math.floor(age / (1000 * 60 * 60 * 24))
|
|
33
|
+
const hours = Math.floor((age % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
|
|
34
|
+
|
|
35
|
+
if (days > 0) return `${days}d ${hours}h`
|
|
36
|
+
if (hours > 0) return `${hours}h`
|
|
37
|
+
return 'Just created'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const formatRetentionPeriod = (seconds) => {
|
|
41
|
+
const days = Math.floor(seconds / (60 * 60 * 24))
|
|
42
|
+
const hours = Math.floor((seconds % (60 * 60 * 24)) / (60 * 60))
|
|
43
|
+
return `${days}d ${hours}h`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="space-y-4">
|
|
48
|
+
<Card>
|
|
49
|
+
<h3 className="text-lg font-semibold mb-4">
|
|
50
|
+
SQS Queues ({queues.length})
|
|
51
|
+
</h3>
|
|
52
|
+
|
|
53
|
+
{queues.length === 0 ? (
|
|
54
|
+
<p className="text-gray-500">No SQS queues found for this service</p>
|
|
55
|
+
) : (
|
|
56
|
+
<div className="space-y-4">
|
|
57
|
+
{queues.map((queue, index) => (
|
|
58
|
+
<div key={index} className="border rounded-lg p-4">
|
|
59
|
+
<div className="flex items-start justify-between mb-2">
|
|
60
|
+
<div>
|
|
61
|
+
<h4 className="font-semibold">{queue.queueName}</h4>
|
|
62
|
+
<div className="text-sm text-gray-600">
|
|
63
|
+
<span className="break-all">{queue.queueUrl}</span>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<StatusBadge
|
|
67
|
+
status={getQueueStatus(queue)}
|
|
68
|
+
text={getQueueStatus(queue)}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
{queue.error ? (
|
|
73
|
+
<div className="mt-3 p-3 bg-red-50 rounded text-sm text-red-700">
|
|
74
|
+
Error fetching queue metrics: {queue.error}
|
|
75
|
+
</div>
|
|
76
|
+
) : (
|
|
77
|
+
<>
|
|
78
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mt-4">
|
|
79
|
+
<div>
|
|
80
|
+
<div className="text-sm text-gray-600">Available</div>
|
|
81
|
+
<div className="text-xl font-mono">
|
|
82
|
+
{queue.messagesAvailable || 0}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div>
|
|
86
|
+
<div className="text-sm text-gray-600">In Flight</div>
|
|
87
|
+
<div className="text-xl font-mono text-blue-600">
|
|
88
|
+
{queue.messagesInFlight || 0}
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
<div>
|
|
92
|
+
<div className="text-sm text-gray-600">Delayed</div>
|
|
93
|
+
<div className="text-xl font-mono text-yellow-600">
|
|
94
|
+
{queue.messagesDelayed || 0}
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
<div>
|
|
98
|
+
<div className="text-sm text-gray-600">Total</div>
|
|
99
|
+
<div className="text-xl font-mono">
|
|
100
|
+
{(queue.messagesAvailable || 0) +
|
|
101
|
+
(queue.messagesInFlight || 0) +
|
|
102
|
+
(queue.messagesDelayed || 0)}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div className="grid grid-cols-2 md:grid-cols-3 gap-4 mt-4 pt-4 border-t">
|
|
108
|
+
<div>
|
|
109
|
+
<div className="text-sm text-gray-600">Visibility Timeout</div>
|
|
110
|
+
<div className="font-mono">{queue.visibilityTimeout}s</div>
|
|
111
|
+
</div>
|
|
112
|
+
<div>
|
|
113
|
+
<div className="text-sm text-gray-600">Retention Period</div>
|
|
114
|
+
<div className="font-mono">
|
|
115
|
+
{formatRetentionPeriod(queue.messageRetentionPeriod)}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
<div>
|
|
119
|
+
<div className="text-sm text-gray-600">Age</div>
|
|
120
|
+
<div className="font-mono">
|
|
121
|
+
{formatAge(queue.createdTimestamp)}
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
{queue.messagesAvailable > 100 && (
|
|
127
|
+
<div className="mt-3 p-3 bg-yellow-50 rounded text-sm text-yellow-700">
|
|
128
|
+
⚠️ High message count detected. Queue may be backing up.
|
|
129
|
+
</div>
|
|
130
|
+
)}
|
|
131
|
+
|
|
132
|
+
{queue.messagesInFlight > 10 && (
|
|
133
|
+
<div className="mt-3 p-3 bg-blue-50 rounded text-sm text-blue-700">
|
|
134
|
+
ℹ️ Multiple messages being processed. Monitor for processing delays.
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
</>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
))}
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
</Card>
|
|
144
|
+
|
|
145
|
+
{/* Queue Health Summary */}
|
|
146
|
+
{queues.length > 0 && (
|
|
147
|
+
<Card>
|
|
148
|
+
<h3 className="text-lg font-semibold mb-4">Queue Health Summary</h3>
|
|
149
|
+
|
|
150
|
+
{/* Visual Queue Status */}
|
|
151
|
+
<div className="space-y-3 mb-4">
|
|
152
|
+
{queues.filter(q => !q.error).map((queue, index) => {
|
|
153
|
+
const total = (queue.messagesAvailable || 0) +
|
|
154
|
+
(queue.messagesInFlight || 0) +
|
|
155
|
+
(queue.messagesDelayed || 0)
|
|
156
|
+
const availablePercent = total > 0 ? (queue.messagesAvailable / total) * 100 : 0
|
|
157
|
+
const inFlightPercent = total > 0 ? (queue.messagesInFlight / total) * 100 : 0
|
|
158
|
+
const delayedPercent = total > 0 ? (queue.messagesDelayed / total) * 100 : 0
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div key={index}>
|
|
162
|
+
<div className="flex justify-between text-sm mb-1">
|
|
163
|
+
<span className="font-medium">{queue.queueName}</span>
|
|
164
|
+
<span className="font-mono">{total} messages</span>
|
|
165
|
+
</div>
|
|
166
|
+
<div className="flex h-6 rounded overflow-hidden bg-gray-200">
|
|
167
|
+
{availablePercent > 0 && (
|
|
168
|
+
<div
|
|
169
|
+
className="bg-green-500"
|
|
170
|
+
style={{ width: `${availablePercent}%` }}
|
|
171
|
+
title={`${queue.messagesAvailable} available`}
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
174
|
+
{inFlightPercent > 0 && (
|
|
175
|
+
<div
|
|
176
|
+
className="bg-blue-500"
|
|
177
|
+
style={{ width: `${inFlightPercent}%` }}
|
|
178
|
+
title={`${queue.messagesInFlight} in flight`}
|
|
179
|
+
/>
|
|
180
|
+
)}
|
|
181
|
+
{delayedPercent > 0 && (
|
|
182
|
+
<div
|
|
183
|
+
className="bg-yellow-500"
|
|
184
|
+
style={{ width: `${delayedPercent}%` }}
|
|
185
|
+
title={`${queue.messagesDelayed} delayed`}
|
|
186
|
+
/>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
)
|
|
191
|
+
})}
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div className="flex gap-4 text-xs">
|
|
195
|
+
<div className="flex items-center gap-1">
|
|
196
|
+
<div className="w-3 h-3 bg-green-500 rounded"></div>
|
|
197
|
+
<span>Available</span>
|
|
198
|
+
</div>
|
|
199
|
+
<div className="flex items-center gap-1">
|
|
200
|
+
<div className="w-3 h-3 bg-blue-500 rounded"></div>
|
|
201
|
+
<span>In Flight</span>
|
|
202
|
+
</div>
|
|
203
|
+
<div className="flex items-center gap-1">
|
|
204
|
+
<div className="w-3 h-3 bg-yellow-500 rounded"></div>
|
|
205
|
+
<span>Delayed</span>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
{/* Summary Statistics */}
|
|
210
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mt-6 pt-4 border-t">
|
|
211
|
+
<div>
|
|
212
|
+
<div className="text-sm text-gray-600">Total Messages</div>
|
|
213
|
+
<div className="text-2xl font-mono">
|
|
214
|
+
{queues.reduce((sum, q) => sum +
|
|
215
|
+
(q.messagesAvailable || 0) +
|
|
216
|
+
(q.messagesInFlight || 0) +
|
|
217
|
+
(q.messagesDelayed || 0), 0
|
|
218
|
+
)}
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
<div>
|
|
222
|
+
<div className="text-sm text-gray-600">Available</div>
|
|
223
|
+
<div className="text-2xl font-mono text-green-600">
|
|
224
|
+
{queues.reduce((sum, q) => sum + (q.messagesAvailable || 0), 0)}
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
<div>
|
|
228
|
+
<div className="text-sm text-gray-600">Processing</div>
|
|
229
|
+
<div className="text-2xl font-mono text-blue-600">
|
|
230
|
+
{queues.reduce((sum, q) => sum + (q.messagesInFlight || 0), 0)}
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
<div>
|
|
234
|
+
<div className="text-sm text-gray-600">Delayed</div>
|
|
235
|
+
<div className="text-2xl font-mono text-yellow-600">
|
|
236
|
+
{queues.reduce((sum, q) => sum + (q.messagesDelayed || 0), 0)}
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</Card>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export default SQSMetrics
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Export monitoring components
|
|
2
|
+
export { default as MonitoringDashboard } from './MonitoringDashboard'
|
|
3
|
+
export { default as LambdaMetrics } from './LambdaMetrics'
|
|
4
|
+
export { default as APIGatewayMetrics } from './APIGatewayMetrics'
|
|
5
|
+
export { default as SQSMetrics } from './SQSMetrics'
|
|
6
|
+
export { default as MetricsChart } from './MetricsChart'
|