Skip to content

Commit 46d69b4

Browse files
author
Yuriy Bezsonov
committed
feat(infra): new workspace infrastructure setup
1 parent 600654e commit 46d69b4

125 files changed

Lines changed: 23741 additions & 87 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/renovate.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
extends:
2+
- config:base
3+
schedule:
4+
- "before 6am on monday"
5+
regexManagers:
6+
# Development tools
7+
- fileMatch:
8+
- "^infra/scripts/.*\\.sh$"
9+
matchStrings:
10+
- "NVM_VERSION=\"(?<currentValue>.*?)\""
11+
datasourceTemplate: github-releases
12+
depNameTemplate: nvm-sh/nvm
13+
- fileMatch:
14+
- "^infra/scripts/.*\\.sh$"
15+
matchStrings:
16+
- "NODE_VERSION=\"(?<currentValue>.*?)\""
17+
datasourceTemplate: node-version
18+
depNameTemplate: node
19+
- fileMatch:
20+
- "^infra/scripts/.*\\.sh$"
21+
matchStrings:
22+
- "MAVEN_VERSION=\"(?<currentValue>.*?)\""
23+
datasourceTemplate: github-releases
24+
depNameTemplate: apache/maven
25+
26+
# VS Code tools
27+
- fileMatch:
28+
- "^infra/scripts/.*\\.sh$"
29+
matchStrings:
30+
- "VSCODE_VERSION=\"(?<currentValue>.*?)\""
31+
datasourceTemplate: github-releases
32+
depNameTemplate: coder/code-server
33+
34+
# Kubernetes tools
35+
- fileMatch:
36+
- "^infra/scripts/.*\\.sh$"
37+
matchStrings:
38+
- "KUBECTL_VERSION=\"(?<currentValue>.*?)\""
39+
datasourceTemplate: github-releases
40+
depNameTemplate: kubernetes/kubernetes
41+
- fileMatch:
42+
- "^infra/scripts/.*\\.sh$"
43+
matchStrings:
44+
- "HELM_VERSION=\"(?<currentValue>.*?)\""
45+
datasourceTemplate: github-releases
46+
depNameTemplate: helm/helm
47+
- fileMatch:
48+
- "^infra/scripts/.*\\.sh$"
49+
matchStrings:
50+
- "EKS_NODE_VIEWER_VERSION=\"(?<currentValue>.*?)\""
51+
datasourceTemplate: github-releases
52+
depNameTemplate: awslabs/eks-node-viewer
53+
54+
# Container tools
55+
- fileMatch:
56+
- "^infra/scripts/.*\\.sh$"
57+
matchStrings:
58+
- "SOCI_VERSION=\"(?<currentValue>.*?)\""
59+
datasourceTemplate: github-releases
60+
depNameTemplate: awslabs/soci-snapshotter
61+
62+
# Utilities
63+
- fileMatch:
64+
- "^infra/scripts/.*\\.sh$"
65+
matchStrings:
66+
- "YQ_VERSION=\"(?<currentValue>.*?)\""
67+
datasourceTemplate: github-releases
68+
depNameTemplate: mikefarah/yq
69+
70+
# Commented out tools (disabled for now)
71+
# - fileMatch:
72+
# - "^infra/scripts/.*\\.sh$"
73+
# matchStrings:
74+
# - "# EKSCTL_VERSION=\"(?<currentValue>.*?)\""
75+
# datasourceTemplate: github-releases
76+
# depNameTemplate: weaveworks/eksctl
77+
# - fileMatch:
78+
# - "^infra/scripts/.*\\.sh$"
79+
# matchStrings:
80+
# - "# DOCKER_COMPOSE_VERSION=\"(?<currentValue>.*?)\""
81+
# datasourceTemplate: github-releases
82+
# depNameTemplate: docker/compose

.github/workflows/ci.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
branches: [ "main" ]
1515

1616
jobs:
17-
build:
17+
build-java21:
1818
runs-on: ubuntu-latest
1919
env:
2020
AWS_REGION: 'us-east-1'
@@ -28,7 +28,6 @@ jobs:
2828
cache: maven
2929
- name: Java version
3030
run: java --version
31-
working-directory: ./apps/unicorn-store-spring/
3231
- name: Build unicorn-store-spring with Maven
3332
run: mvn -B clean package --file pom.xml --no-transfer-progress
3433
working-directory: ./apps/unicorn-store-spring/
@@ -37,10 +36,8 @@ jobs:
3736
working-directory: ./apps/unicorn-spring-ai-agent/
3837
- name: Install AWS CDK
3938
run: npm install -g aws-cdk
40-
working-directory: ./infrastructure/cdk/
4139
- name: AWS CDK version
4240
run: cdk version
43-
working-directory: ./infrastructure/cdk/
4441
- name: Build CDK Immersion Day infrastructure
4542
run: mvn clean package --no-transfer-progress
4643
working-directory: ./infrastructure/cdk/
@@ -57,6 +54,37 @@ jobs:
5754
run: docker build -t unicorn-store-javax:latest .
5855
working-directory: ./apps/unicorn-store-javax/
5956

57+
build-java25:
58+
runs-on: ubuntu-latest
59+
env:
60+
AWS_REGION: 'us-east-1'
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Set up JDK 25
64+
uses: actions/setup-java@v4
65+
with:
66+
distribution: 'corretto'
67+
java-version: 25
68+
cache: maven
69+
- name: Java version
70+
run: java --version
71+
- name: Build unicorn-store-spring with Maven
72+
run: mvn -B clean package --file pom.xml --no-transfer-progress
73+
working-directory: ./apps/unicorn-store-spring-java25/
74+
- name: Build jvm-ai-analyzer with Maven
75+
run: mvn -B clean package --file pom.xml --no-transfer-progress
76+
working-directory: ./apps/jvm-analysis-service/
77+
- name: Install AWS CDK
78+
run: npm install -g aws-cdk
79+
- name: AWS CDK version
80+
run: cdk version
81+
- name: Build infra CDK
82+
run: mvn clean package --no-transfer-progress
83+
working-directory: ./infra/cdk/
84+
- name: CDK Synth infra
85+
run: cdk synth
86+
working-directory: ./infra/cdk/
87+
6088
# - name: Submit Dependency Snapshot
6189
# uses: advanced-security/maven-dependency-submission-action@v4
6290
# with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ build/
3535
### VS Code ###
3636
.vscode/
3737

38+
### Kiro ###
39+
.kiro/debug/
3840

3941
### Other
4042

apps/ai-jvm-analyzer/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
target/
2+
*.class
3+
*.jar
4+
*.log
5+
.idea/
6+
*.iml
7+
.DS_Store
8+
.jqwik-database

apps/ai-jvm-analyzer/README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# AI JVM Analyzer
2+
3+
AI-powered JVM performance analyzer using Amazon Bedrock. Receives webhook alerts from monitoring systems (Grafana, CloudWatch), collects thread dumps and profiling data, and generates actionable performance analysis reports.
4+
5+
## Architecture
6+
7+
```
8+
┌─────────────────────────────────────────────────────────────┐
9+
│ Monitoring System (Grafana/CloudWatch/Prometheus) │
10+
│ - Detects high CPU, memory, or thread count alerts │
11+
└─────────────────────────────────────────────────────────────┘
12+
13+
▼ POST /webhook
14+
┌─────────────────────────────────────────────────────────────┐
15+
│ WebhookController │
16+
│ - Receives alert payloads with pod name and IP │
17+
│ - Validates alerts, filters invalid entries │
18+
└─────────────────────────────────────────────────────────────┘
19+
20+
21+
┌─────────────────────────────────────────────────────────────┐
22+
│ AnalyzerService │
23+
│ - Parallel processing with Virtual Threads │
24+
│ - Fetches thread dump from pod's /actuator/threaddump │
25+
│ - Retrieves profiling data (flamegraph) from S3 │
26+
└─────────────────────────────────────────────────────────────┘
27+
28+
┌───────────────┴───────────────┐
29+
▼ ▼
30+
┌─────────────────────────┐ ┌─────────────────────────┐
31+
│ AiService │ │ S3Repository │
32+
│ - Spring AI + Bedrock │ │ - Fetch profiling data │
33+
│ - Claude Sonnet 4 │ │ - Store analysis │
34+
│ - Structured prompts │ │ - Thread dumps │
35+
└─────────────────────────┘ └─────────────────────────┘
36+
```
37+
38+
## Project Structure
39+
40+
```
41+
src/main/java/com/example/ai/jvmanalyzer/
42+
├── Application.java # Spring Boot entry point, beans config
43+
├── WebhookController.java # REST endpoint for monitoring webhooks
44+
├── AnalyzerService.java # Orchestrates analysis workflow
45+
├── AiService.java # Bedrock integration via Spring AI
46+
└── S3Repository.java # S3 storage for profiling data and results
47+
```
48+
49+
## How It Works
50+
51+
1. Monitoring system detects performance issue (high CPU, thread count, etc.)
52+
2. Alert webhook sent to `/webhook` with pod name and IP address
53+
3. Analyzer fetches thread dump from the pod's actuator endpoint
54+
4. Retrieves latest flamegraph/profiling data from S3
55+
5. Sends both to Claude Sonnet 4 for analysis
56+
6. Stores thread dump, profiling data, and AI analysis report in S3
57+
58+
## Webhook Payload Format
59+
60+
```json
61+
{
62+
"alerts": [
63+
{
64+
"labels": {
65+
"pod": "unicorn-store-spring-abc123",
66+
"instance": "10.0.1.50:8080"
67+
}
68+
}
69+
]
70+
}
71+
```
72+
73+
## Analysis Report Contents
74+
75+
The AI generates a structured report including:
76+
- Health status (Healthy/Degraded/Critical)
77+
- Thread analysis with state distribution
78+
- Top 3 critical issues with root cause and fix
79+
- Performance hotspots from flamegraph
80+
- Immediate and short-term recommendations
81+
82+
## Dependencies
83+
84+
| Dependency | Version | Purpose |
85+
|------------|---------|---------|
86+
| Spring Boot | 4.0.1 | Application framework |
87+
| Spring AI | 1.1.1 | Bedrock integration |
88+
| AWS SDK | 2.40.15 | S3 client |
89+
| Testcontainers | 2.0.3 | Integration testing |
90+
| jqwik | 1.9.3 | Property-based testing |
91+
92+
## Configuration
93+
94+
| Property | Default | Description |
95+
|----------|---------|-------------|
96+
| `analyzer.thread-dump.url-template` | `http://{podIp}:8080/actuator/threaddump` | Thread dump endpoint |
97+
| `analyzer.s3.bucket` | `ai-jvm-analyzer-bucket` | S3 bucket for storage |
98+
| `analyzer.s3.prefix.analysis` | `analysis/` | Prefix for analysis results |
99+
| `analyzer.s3.prefix.profiling` | `profiling/` | Prefix for profiling data |
100+
| `spring.ai.bedrock.converse.chat.options.model` | `anthropic.claude-sonnet-4-20250514-v1:0` | Bedrock model |
101+
102+
## Environment Variables
103+
104+
| Variable | Required | Description |
105+
|----------|----------|-------------|
106+
| `AWS_REGION` | Yes | AWS region for Bedrock and S3 |
107+
| `AWS_S3_BUCKET` | Yes | S3 bucket name |
108+
109+
## Building
110+
111+
```bash
112+
mvn package # Standard JAR
113+
mvn package -Pnative # Native image (GraalVM 25)
114+
mvn jib:dockerBuild # Container with Jib
115+
```
116+
117+
## API Endpoints
118+
119+
| Method | Endpoint | Description |
120+
|--------|----------|-------------|
121+
| POST | `/webhook` | Receive monitoring alerts |
122+
| GET | `/actuator/health` | Health check |
123+
| GET | `/actuator/prometheus` | Metrics |
124+
125+
## S3 Storage Layout
126+
127+
```
128+
s3://ai-jvm-analyzer-bucket/
129+
├── profiling/
130+
│ └── {pod-name}/
131+
│ └── profile-{yyyyMMdd}-{timestamp}.html # Flamegraph data
132+
└── analysis/
133+
├── {timestamp}_threaddump_{pod-name}.json # Raw thread dump
134+
├── {timestamp}_profiling_{pod-name}.html # Profiling snapshot
135+
└── {timestamp}_analysis_{pod-name}.md # AI analysis report
136+
```
137+
138+
## IAM Permissions Required
139+
140+
```json
141+
{
142+
"Version": "2012-10-17",
143+
"Statement": [
144+
{
145+
"Effect": "Allow",
146+
"Action": [
147+
"s3:GetObject",
148+
"s3:PutObject",
149+
"s3:ListBucket"
150+
],
151+
"Resource": [
152+
"arn:aws:s3:::ai-jvm-analyzer-bucket",
153+
"arn:aws:s3:::ai-jvm-analyzer-bucket/*"
154+
]
155+
},
156+
{
157+
"Effect": "Allow",
158+
"Action": "bedrock:InvokeModel",
159+
"Resource": "arn:aws:bedrock:*::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0"
160+
}
161+
]
162+
}
163+
```

0 commit comments

Comments
 (0)