@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,21 @@
|
|
|
1
|
+
// Layout components
|
|
2
|
+
export { default as Layout } from './Layout'
|
|
3
|
+
export { default as ErrorBoundary } from './ErrorBoundary'
|
|
4
|
+
|
|
5
|
+
// UI components
|
|
6
|
+
export { Card, CardHeader, CardContent, CardTitle, CardDescription } from './Card'
|
|
7
|
+
export { Button } from './Button'
|
|
8
|
+
export { default as StatusBadge } from './StatusBadge'
|
|
9
|
+
export { default as LoadingSpinner } from './LoadingSpinner'
|
|
10
|
+
export { default as IntegrationCard } from './IntegrationCard'
|
|
11
|
+
export { default as UserContextSwitcher } from './UserContextSwitcher'
|
|
12
|
+
|
|
13
|
+
// Connection components
|
|
14
|
+
export * from './connections'
|
|
15
|
+
|
|
16
|
+
// Environment components
|
|
17
|
+
export { default as EnvironmentEditor } from './EnvironmentEditor'
|
|
18
|
+
export { default as EnvironmentSchema } from './EnvironmentSchema'
|
|
19
|
+
export { default as EnvironmentCompare } from './EnvironmentCompare'
|
|
20
|
+
export { default as EnvironmentImportExport } from './EnvironmentImportExport'
|
|
21
|
+
export { default as EnvironmentSecurity } from './EnvironmentSecurity'
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Card } from '../Card'
|
|
3
|
+
import { StatusBadge } from '../StatusBadge'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* API Gateway Metrics Component
|
|
7
|
+
* Displays detailed metrics for AWS API Gateway endpoints
|
|
8
|
+
*/
|
|
9
|
+
function APIGatewayMetrics({ metrics }) {
|
|
10
|
+
if (!metrics || metrics.error) {
|
|
11
|
+
return (
|
|
12
|
+
<Card>
|
|
13
|
+
<div className="text-center py-8 text-gray-500">
|
|
14
|
+
{metrics?.error || 'No API Gateway metrics available'}
|
|
15
|
+
</div>
|
|
16
|
+
</Card>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { apis = [] } = metrics
|
|
21
|
+
|
|
22
|
+
const getStatusFromMetrics = (api) => {
|
|
23
|
+
if (api.metrics?.['5xxerror'] > 0) return 'error'
|
|
24
|
+
if (api.metrics?.['4xxerror'] > 0) return 'warning'
|
|
25
|
+
if (api.metrics?.count > 0) return 'success'
|
|
26
|
+
return 'inactive'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const formatLatency = (latency) => {
|
|
30
|
+
if (!latency) return '0ms'
|
|
31
|
+
return `${Math.round(latency)}ms`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="space-y-4">
|
|
36
|
+
<Card>
|
|
37
|
+
<h3 className="text-lg font-semibold mb-4">
|
|
38
|
+
API Gateways ({apis.length})
|
|
39
|
+
</h3>
|
|
40
|
+
|
|
41
|
+
{apis.length === 0 ? (
|
|
42
|
+
<p className="text-gray-500">No API Gateways found for this service</p>
|
|
43
|
+
) : (
|
|
44
|
+
<div className="space-y-4">
|
|
45
|
+
{apis.map((api, index) => (
|
|
46
|
+
<div key={index} className="border rounded-lg p-4">
|
|
47
|
+
<div className="flex items-start justify-between mb-2">
|
|
48
|
+
<div>
|
|
49
|
+
<h4 className="font-semibold">{api.apiName}</h4>
|
|
50
|
+
<div className="text-sm text-gray-600">
|
|
51
|
+
<span>ID: {api.apiId}</span>
|
|
52
|
+
{api.description && (
|
|
53
|
+
<span className="ml-4">{api.description}</span>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<StatusBadge
|
|
58
|
+
status={getStatusFromMetrics(api)}
|
|
59
|
+
text={getStatusFromMetrics(api)}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
{api.metrics && (
|
|
64
|
+
<div className="grid grid-cols-2 md:grid-cols-6 gap-4 mt-4">
|
|
65
|
+
<div>
|
|
66
|
+
<div className="text-sm text-gray-600">Total Requests</div>
|
|
67
|
+
<div className="text-xl font-mono">
|
|
68
|
+
{api.metrics.count || 0}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<div>
|
|
72
|
+
<div className="text-sm text-gray-600">4XX Errors</div>
|
|
73
|
+
<div className="text-xl font-mono text-yellow-600">
|
|
74
|
+
{api.metrics['4xxerror'] || 0}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
<div>
|
|
78
|
+
<div className="text-sm text-gray-600">5XX Errors</div>
|
|
79
|
+
<div className="text-xl font-mono text-red-600">
|
|
80
|
+
{api.metrics['5xxerror'] || 0}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div>
|
|
84
|
+
<div className="text-sm text-gray-600">Error Rate</div>
|
|
85
|
+
<div className="text-xl font-mono">
|
|
86
|
+
{api.metrics.errorRate?.toFixed(2) || 0}%
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div>
|
|
90
|
+
<div className="text-sm text-gray-600">Avg Latency</div>
|
|
91
|
+
<div className="text-xl font-mono">
|
|
92
|
+
{formatLatency(api.metrics.latency)}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<div>
|
|
96
|
+
<div className="text-sm text-gray-600">Integration</div>
|
|
97
|
+
<div className="text-xl font-mono">
|
|
98
|
+
{formatLatency(api.metrics.integrationlatency)}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{api.metrics && (api.metrics['5xxerror'] > 0 || api.metrics.errorRate > 5) && (
|
|
105
|
+
<div className="mt-3 p-3 bg-red-50 rounded text-sm">
|
|
106
|
+
{api.metrics['5xxerror'] > 0 && (
|
|
107
|
+
<div className="text-red-700">
|
|
108
|
+
⚠️ Server errors detected. Check Lambda function logs and API Gateway execution logs.
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
{api.metrics.errorRate > 5 && (
|
|
112
|
+
<div className="text-yellow-700">
|
|
113
|
+
⚠️ High error rate detected ({api.metrics.errorRate.toFixed(2)}%). Review recent deployments.
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
<div className="text-xs text-gray-500 mt-2">
|
|
120
|
+
Created: {new Date(api.createdDate).toLocaleString()}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
</Card>
|
|
127
|
+
|
|
128
|
+
{/* Performance Analysis */}
|
|
129
|
+
{apis.length > 0 && apis.some(api => api.metrics?.count > 0) && (
|
|
130
|
+
<Card>
|
|
131
|
+
<h3 className="text-lg font-semibold mb-4">Performance Analysis</h3>
|
|
132
|
+
<div className="space-y-4">
|
|
133
|
+
{/* Latency Distribution */}
|
|
134
|
+
<div>
|
|
135
|
+
<h4 className="font-medium mb-2">Latency Breakdown</h4>
|
|
136
|
+
<div className="space-y-2">
|
|
137
|
+
{apis.filter(api => api.metrics?.latency > 0).map((api, index) => {
|
|
138
|
+
const totalLatency = api.metrics.latency || 0
|
|
139
|
+
const integrationLatency = api.metrics.integrationlatency || 0
|
|
140
|
+
const gatewayLatency = totalLatency - integrationLatency
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div key={index} className="flex items-center gap-2">
|
|
144
|
+
<div className="w-32 text-sm truncate">{api.apiName}</div>
|
|
145
|
+
<div className="flex-1 flex h-6 rounded overflow-hidden">
|
|
146
|
+
<div
|
|
147
|
+
className="bg-blue-500 flex items-center justify-center text-xs text-white"
|
|
148
|
+
style={{ width: `${(gatewayLatency / totalLatency) * 100}%` }}
|
|
149
|
+
>
|
|
150
|
+
{formatLatency(gatewayLatency)}
|
|
151
|
+
</div>
|
|
152
|
+
<div
|
|
153
|
+
className="bg-green-500 flex items-center justify-center text-xs text-white"
|
|
154
|
+
style={{ width: `${(integrationLatency / totalLatency) * 100}%` }}
|
|
155
|
+
>
|
|
156
|
+
{formatLatency(integrationLatency)}
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
<div className="text-sm font-mono w-20 text-right">
|
|
160
|
+
{formatLatency(totalLatency)}
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
})}
|
|
165
|
+
</div>
|
|
166
|
+
<div className="flex gap-4 mt-2 text-xs">
|
|
167
|
+
<div className="flex items-center gap-1">
|
|
168
|
+
<div className="w-3 h-3 bg-blue-500 rounded"></div>
|
|
169
|
+
<span>Gateway Overhead</span>
|
|
170
|
+
</div>
|
|
171
|
+
<div className="flex items-center gap-1">
|
|
172
|
+
<div className="w-3 h-3 bg-green-500 rounded"></div>
|
|
173
|
+
<span>Integration (Lambda)</span>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
{/* Summary Statistics */}
|
|
179
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 pt-4 border-t">
|
|
180
|
+
<div>
|
|
181
|
+
<div className="text-sm text-gray-600">Total Requests</div>
|
|
182
|
+
<div className="text-2xl font-mono">
|
|
183
|
+
{apis.reduce((sum, api) => sum + (api.metrics?.count || 0), 0)}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
<div>
|
|
187
|
+
<div className="text-sm text-gray-600">Total Errors</div>
|
|
188
|
+
<div className="text-2xl font-mono text-red-600">
|
|
189
|
+
{apis.reduce((sum, api) => sum + (api.metrics?.['4xxerror'] || 0) + (api.metrics?.['5xxerror'] || 0), 0)}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
<div>
|
|
193
|
+
<div className="text-sm text-gray-600">Avg Error Rate</div>
|
|
194
|
+
<div className="text-2xl font-mono">
|
|
195
|
+
{(() => {
|
|
196
|
+
const validApis = apis.filter(api => api.metrics?.count > 0)
|
|
197
|
+
if (validApis.length === 0) return '0%'
|
|
198
|
+
const avgErrorRate = validApis.reduce((sum, api) => sum + (api.metrics.errorRate || 0), 0) / validApis.length
|
|
199
|
+
return `${avgErrorRate.toFixed(2)}%`
|
|
200
|
+
})()}
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
<div>
|
|
204
|
+
<div className="text-sm text-gray-600">Avg Latency</div>
|
|
205
|
+
<div className="text-2xl font-mono">
|
|
206
|
+
{(() => {
|
|
207
|
+
const validApis = apis.filter(api => api.metrics?.latency > 0)
|
|
208
|
+
if (validApis.length === 0) return '0ms'
|
|
209
|
+
const avgLatency = validApis.reduce((sum, api) => sum + api.metrics.latency, 0) / validApis.length
|
|
210
|
+
return formatLatency(avgLatency)
|
|
211
|
+
})()}
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
</Card>
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export default APIGatewayMetrics
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Card } from '../Card'
|
|
3
|
+
import { StatusBadge } from '../StatusBadge'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Lambda Functions Metrics Component
|
|
7
|
+
* Displays detailed metrics for AWS Lambda functions
|
|
8
|
+
*/
|
|
9
|
+
function LambdaMetrics({ metrics }) {
|
|
10
|
+
if (!metrics || metrics.error) {
|
|
11
|
+
return (
|
|
12
|
+
<Card>
|
|
13
|
+
<div className="text-center py-8 text-gray-500">
|
|
14
|
+
{metrics?.error || 'No Lambda metrics available'}
|
|
15
|
+
</div>
|
|
16
|
+
</Card>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { functions = [] } = metrics
|
|
21
|
+
|
|
22
|
+
const getStatusFromMetrics = (fn) => {
|
|
23
|
+
if (fn.metrics?.errors > 0) return 'error'
|
|
24
|
+
if (fn.metrics?.throttles > 0) return 'warning'
|
|
25
|
+
if (fn.metrics?.invocations > 0) return 'success'
|
|
26
|
+
return 'inactive'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const formatDuration = (duration) => {
|
|
30
|
+
if (!duration) return '0ms'
|
|
31
|
+
if (duration < 1000) return `${Math.round(duration)}ms`
|
|
32
|
+
return `${(duration / 1000).toFixed(2)}s`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="space-y-4">
|
|
37
|
+
<Card>
|
|
38
|
+
<h3 className="text-lg font-semibold mb-4">
|
|
39
|
+
Lambda Functions ({functions.length})
|
|
40
|
+
</h3>
|
|
41
|
+
|
|
42
|
+
{functions.length === 0 ? (
|
|
43
|
+
<p className="text-gray-500">No Lambda functions found for this service</p>
|
|
44
|
+
) : (
|
|
45
|
+
<div className="space-y-4">
|
|
46
|
+
{functions.map((fn, index) => (
|
|
47
|
+
<div key={index} className="border rounded-lg p-4">
|
|
48
|
+
<div className="flex items-start justify-between mb-2">
|
|
49
|
+
<div>
|
|
50
|
+
<h4 className="font-semibold">{fn.functionName}</h4>
|
|
51
|
+
<div className="text-sm text-gray-600 space-x-4">
|
|
52
|
+
<span>Runtime: {fn.runtime}</span>
|
|
53
|
+
<span>Memory: {fn.memorySize}MB</span>
|
|
54
|
+
<span>Timeout: {fn.timeout}s</span>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<StatusBadge
|
|
58
|
+
status={getStatusFromMetrics(fn)}
|
|
59
|
+
text={getStatusFromMetrics(fn)}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
{fn.metrics && (
|
|
64
|
+
<div className="grid grid-cols-2 md:grid-cols-5 gap-4 mt-4">
|
|
65
|
+
<div>
|
|
66
|
+
<div className="text-sm text-gray-600">Invocations</div>
|
|
67
|
+
<div className="text-xl font-mono">
|
|
68
|
+
{fn.metrics.invocations || 0}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<div>
|
|
72
|
+
<div className="text-sm text-gray-600">Errors</div>
|
|
73
|
+
<div className="text-xl font-mono text-red-600">
|
|
74
|
+
{fn.metrics.errors || 0}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
<div>
|
|
78
|
+
<div className="text-sm text-gray-600">Avg Duration</div>
|
|
79
|
+
<div className="text-xl font-mono">
|
|
80
|
+
{formatDuration(fn.metrics.duration)}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div>
|
|
84
|
+
<div className="text-sm text-gray-600">Throttles</div>
|
|
85
|
+
<div className="text-xl font-mono text-yellow-600">
|
|
86
|
+
{fn.metrics.throttles || 0}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div>
|
|
90
|
+
<div className="text-sm text-gray-600">Concurrent</div>
|
|
91
|
+
<div className="text-xl font-mono">
|
|
92
|
+
{Math.round(fn.metrics.concurrentexecutions || 0)}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
|
|
98
|
+
{fn.metrics && (fn.metrics.errors > 0 || fn.metrics.throttles > 0) && (
|
|
99
|
+
<div className="mt-3 p-3 bg-red-50 rounded text-sm">
|
|
100
|
+
{fn.metrics.errors > 0 && (
|
|
101
|
+
<div className="text-red-700">
|
|
102
|
+
⚠️ This function has errors. Check CloudWatch logs for details.
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
{fn.metrics.throttles > 0 && (
|
|
106
|
+
<div className="text-yellow-700">
|
|
107
|
+
⚠️ This function is being throttled. Consider increasing reserved concurrency.
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
|
|
113
|
+
<div className="text-xs text-gray-500 mt-2">
|
|
114
|
+
Last modified: {new Date(fn.lastModified).toLocaleString()}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</Card>
|
|
121
|
+
|
|
122
|
+
{/* Summary Statistics */}
|
|
123
|
+
{functions.length > 0 && (
|
|
124
|
+
<Card>
|
|
125
|
+
<h3 className="text-lg font-semibold mb-4">Summary Statistics</h3>
|
|
126
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
127
|
+
<div>
|
|
128
|
+
<div className="text-sm text-gray-600">Total Invocations</div>
|
|
129
|
+
<div className="text-2xl font-mono">
|
|
130
|
+
{functions.reduce((sum, fn) => sum + (fn.metrics?.invocations || 0), 0)}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
<div>
|
|
134
|
+
<div className="text-sm text-gray-600">Total Errors</div>
|
|
135
|
+
<div className="text-2xl font-mono text-red-600">
|
|
136
|
+
{functions.reduce((sum, fn) => sum + (fn.metrics?.errors || 0), 0)}
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
<div>
|
|
140
|
+
<div className="text-sm text-gray-600">Error Rate</div>
|
|
141
|
+
<div className="text-2xl font-mono">
|
|
142
|
+
{(() => {
|
|
143
|
+
const totalInvocations = functions.reduce((sum, fn) => sum + (fn.metrics?.invocations || 0), 0)
|
|
144
|
+
const totalErrors = functions.reduce((sum, fn) => sum + (fn.metrics?.errors || 0), 0)
|
|
145
|
+
return totalInvocations > 0
|
|
146
|
+
? `${((totalErrors / totalInvocations) * 100).toFixed(2)}%`
|
|
147
|
+
: '0%'
|
|
148
|
+
})()}
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
<div>
|
|
152
|
+
<div className="text-sm text-gray-600">Avg Duration</div>
|
|
153
|
+
<div className="text-2xl font-mono">
|
|
154
|
+
{(() => {
|
|
155
|
+
const validFunctions = functions.filter(fn => fn.metrics?.duration > 0)
|
|
156
|
+
if (validFunctions.length === 0) return '0ms'
|
|
157
|
+
const avgDuration = validFunctions.reduce((sum, fn) => sum + fn.metrics.duration, 0) / validFunctions.length
|
|
158
|
+
return formatDuration(avgDuration)
|
|
159
|
+
})()}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</Card>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export default LambdaMetrics
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Card } from '../Card'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Metrics Charts Component
|
|
6
|
+
* Displays visual charts for metrics data
|
|
7
|
+
* Note: This is a placeholder for future chart implementation
|
|
8
|
+
*/
|
|
9
|
+
function MetricsChart({ metrics }) {
|
|
10
|
+
if (!metrics) {
|
|
11
|
+
return (
|
|
12
|
+
<Card>
|
|
13
|
+
<div className="text-center py-8 text-gray-500">
|
|
14
|
+
No metrics data available for charting
|
|
15
|
+
</div>
|
|
16
|
+
</Card>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Simple bar chart implementation using CSS
|
|
21
|
+
const renderSimpleBarChart = (data, title, color = 'blue') => {
|
|
22
|
+
if (!data || data.length === 0) return null
|
|
23
|
+
|
|
24
|
+
const maxValue = Math.max(...data.map(d => d.value))
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="mb-6">
|
|
28
|
+
<h4 className="font-medium mb-3">{title}</h4>
|
|
29
|
+
<div className="space-y-2">
|
|
30
|
+
{data.map((item, index) => (
|
|
31
|
+
<div key={index} className="flex items-center gap-3">
|
|
32
|
+
<div className="w-32 text-sm truncate">{item.label}</div>
|
|
33
|
+
<div className="flex-1 flex items-center">
|
|
34
|
+
<div className="flex-1 bg-gray-200 rounded h-6 relative">
|
|
35
|
+
<div
|
|
36
|
+
className={`bg-${color}-500 h-full rounded transition-all duration-300`}
|
|
37
|
+
style={{ width: `${(item.value / maxValue) * 100}%` }}
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
<span className="ml-2 text-sm font-mono w-16 text-right">
|
|
41
|
+
{item.value}
|
|
42
|
+
</span>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Prepare chart data
|
|
52
|
+
const lambdaInvocationsData = metrics.lambda?.functions?.map(fn => ({
|
|
53
|
+
label: fn.functionName.split('-').pop() || fn.functionName,
|
|
54
|
+
value: fn.metrics?.invocations || 0
|
|
55
|
+
})) || []
|
|
56
|
+
|
|
57
|
+
const lambdaErrorsData = metrics.lambda?.functions?.map(fn => ({
|
|
58
|
+
label: fn.functionName.split('-').pop() || fn.functionName,
|
|
59
|
+
value: fn.metrics?.errors || 0
|
|
60
|
+
})) || []
|
|
61
|
+
|
|
62
|
+
const apiRequestsData = metrics.apiGateway?.apis?.map(api => ({
|
|
63
|
+
label: api.apiName.split('-').pop() || api.apiName,
|
|
64
|
+
value: api.metrics?.count || 0
|
|
65
|
+
})) || []
|
|
66
|
+
|
|
67
|
+
const queueMessagesData = metrics.sqs?.queues?.map(queue => ({
|
|
68
|
+
label: queue.queueName.split('-').pop() || queue.queueName,
|
|
69
|
+
value: (queue.messagesAvailable || 0) + (queue.messagesInFlight || 0)
|
|
70
|
+
})) || []
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div className="space-y-6">
|
|
74
|
+
<Card>
|
|
75
|
+
<h3 className="text-lg font-semibold mb-4">Metrics Visualization</h3>
|
|
76
|
+
<p className="text-gray-600 mb-6">
|
|
77
|
+
Visual representation of your Frigg application metrics.
|
|
78
|
+
Charts are updated in real-time as new metrics are collected.
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
{/* Lambda Invocations Chart */}
|
|
82
|
+
{lambdaInvocationsData.length > 0 && (
|
|
83
|
+
renderSimpleBarChart(
|
|
84
|
+
lambdaInvocationsData.filter(d => d.value > 0),
|
|
85
|
+
'Lambda Function Invocations (Last Hour)',
|
|
86
|
+
'blue'
|
|
87
|
+
)
|
|
88
|
+
)}
|
|
89
|
+
|
|
90
|
+
{/* Lambda Errors Chart */}
|
|
91
|
+
{lambdaErrorsData.some(d => d.value > 0) && (
|
|
92
|
+
renderSimpleBarChart(
|
|
93
|
+
lambdaErrorsData.filter(d => d.value > 0),
|
|
94
|
+
'Lambda Function Errors (Last Hour)',
|
|
95
|
+
'red'
|
|
96
|
+
)
|
|
97
|
+
)}
|
|
98
|
+
|
|
99
|
+
{/* API Gateway Requests Chart */}
|
|
100
|
+
{apiRequestsData.length > 0 && (
|
|
101
|
+
renderSimpleBarChart(
|
|
102
|
+
apiRequestsData.filter(d => d.value > 0),
|
|
103
|
+
'API Gateway Requests (Last Hour)',
|
|
104
|
+
'green'
|
|
105
|
+
)
|
|
106
|
+
)}
|
|
107
|
+
|
|
108
|
+
{/* SQS Messages Chart */}
|
|
109
|
+
{queueMessagesData.length > 0 && (
|
|
110
|
+
renderSimpleBarChart(
|
|
111
|
+
queueMessagesData.filter(d => d.value > 0),
|
|
112
|
+
'SQS Queue Messages',
|
|
113
|
+
'yellow'
|
|
114
|
+
)
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{/* Performance Comparison */}
|
|
118
|
+
{metrics.lambda?.functions?.length > 0 && (
|
|
119
|
+
<div className="mt-8">
|
|
120
|
+
<h4 className="font-medium mb-3">Average Duration Comparison</h4>
|
|
121
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
122
|
+
{metrics.lambda.functions
|
|
123
|
+
.filter(fn => fn.metrics?.duration > 0)
|
|
124
|
+
.sort((a, b) => (b.metrics?.duration || 0) - (a.metrics?.duration || 0))
|
|
125
|
+
.map((fn, index) => (
|
|
126
|
+
<div key={index} className="border rounded p-3">
|
|
127
|
+
<div className="text-sm font-medium truncate">
|
|
128
|
+
{fn.functionName.split('-').pop() || fn.functionName}
|
|
129
|
+
</div>
|
|
130
|
+
<div className="text-2xl font-mono">
|
|
131
|
+
{fn.metrics.duration < 1000
|
|
132
|
+
? `${Math.round(fn.metrics.duration)}ms`
|
|
133
|
+
: `${(fn.metrics.duration / 1000).toFixed(2)}s`
|
|
134
|
+
}
|
|
135
|
+
</div>
|
|
136
|
+
<div className="text-xs text-gray-500">
|
|
137
|
+
{fn.metrics.invocations} invocations
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
))
|
|
141
|
+
}
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
{/* Health Score */}
|
|
147
|
+
<div className="mt-8 p-4 bg-gray-50 rounded">
|
|
148
|
+
<h4 className="font-medium mb-2">System Health Score</h4>
|
|
149
|
+
<div className="flex items-center gap-4">
|
|
150
|
+
<div className="flex-1">
|
|
151
|
+
{(() => {
|
|
152
|
+
const totalInvocations = metrics.lambda?.functions?.reduce(
|
|
153
|
+
(sum, fn) => sum + (fn.metrics?.invocations || 0), 0
|
|
154
|
+
) || 0
|
|
155
|
+
const totalErrors = metrics.lambda?.functions?.reduce(
|
|
156
|
+
(sum, fn) => sum + (fn.metrics?.errors || 0), 0
|
|
157
|
+
) || 0
|
|
158
|
+
const errorRate = totalInvocations > 0 ? (totalErrors / totalInvocations) * 100 : 0
|
|
159
|
+
const healthScore = Math.max(0, 100 - errorRate * 10)
|
|
160
|
+
|
|
161
|
+
let healthColor = 'green'
|
|
162
|
+
if (healthScore < 80) healthColor = 'yellow'
|
|
163
|
+
if (healthScore < 60) healthColor = 'red'
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<div className="flex justify-between text-sm mb-1">
|
|
168
|
+
<span>Overall Health</span>
|
|
169
|
+
<span>{Math.round(healthScore)}%</span>
|
|
170
|
+
</div>
|
|
171
|
+
<div className="w-full bg-gray-200 rounded-full h-4">
|
|
172
|
+
<div
|
|
173
|
+
className={`bg-${healthColor}-500 h-4 rounded-full transition-all duration-300`}
|
|
174
|
+
style={{ width: `${healthScore}%` }}
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
<div className="text-xs text-gray-600 mt-1">
|
|
178
|
+
Based on error rates and response times
|
|
179
|
+
</div>
|
|
180
|
+
</>
|
|
181
|
+
)
|
|
182
|
+
})()}
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
{/* Future Chart Integration Notice */}
|
|
188
|
+
<div className="mt-8 p-4 bg-blue-50 rounded text-sm text-blue-700">
|
|
189
|
+
<strong>Coming Soon:</strong> Interactive time-series charts with Chart.js or D3.js
|
|
190
|
+
for historical trend analysis and real-time metric streaming.
|
|
191
|
+
</div>
|
|
192
|
+
</Card>
|
|
193
|
+
</div>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default MetricsChart
|