Skip to content

Commit 9285d6a

Browse files
committed
Switch to a common account id field
1 parent 620e28a commit 9285d6a

File tree

12 files changed

+26
-43
lines changed

12 files changed

+26
-43
lines changed

lambdas/collector/__tests__/transformers/base.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestTransformer extends BaseTransformer {
1616
priority: this.extractPriority(rawPayload.priority),
1717
occurred_at: this.parseTimestamp(rawPayload.timestamp),
1818
team: this.extractTeam(rawPayload.team),
19-
identity: { org_id: "", rule_id: "" },
19+
identity: { account_id: "", rule_id: "" },
2020
links: {},
2121
raw_provider: rawPayload,
2222
};

lambdas/collector/__tests__/transformers/cloudwatch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("CloudWatchTransformer", () => {
3131
priority: "P2",
3232
team: "platform",
3333
identity: {
34-
aws_account: "123456789012",
34+
account_id: "123456789012",
3535
region: "us-east-1",
3636
alarm_arn: "arn:aws:cloudwatch:us-east-1:123456789012:alarm:HighCPU",
3737
},

lambdas/collector/__tests__/transformers/grafana.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("GrafanaTransformer", () => {
3232
priority: "P1",
3333
team: "dev-infra",
3434
identity: {
35-
org_id: "1",
35+
account_id: "1",
3636
rule_id: "abc123",
3737
},
3838
links: {
@@ -167,7 +167,7 @@ describe("GrafanaTransformer", () => {
167167
const result = transformer.transform(payload, mockEnvelope);
168168

169169
expect(result.identity).toMatchObject({
170-
org_id: "42",
170+
account_id: "42",
171171
rule_id: "unique-fingerprint-123",
172172
});
173173
});

lambdas/collector/__tests__/transformers/normalized.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("NormalizedTransformer", () => {
1717
occurred_at: "2024-01-15T10:30:00.000Z",
1818
team: "platform-team",
1919
identity: {
20-
aws_account: "123456789012",
20+
account_id: "123456789012",
2121
region: "us-west-2",
2222
rule_id: "cpu-high-alert",
2323
},

lambdas/collector/__tests__/utils/schema-validator.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ describe("Schema Validator", () => {
4444
summary: "Test summary",
4545
reason: "Test reason",
4646
identity: {
47-
aws_account: "123456789012",
47+
account_id: "123456789012",
4848
region: "us-west-2",
4949
alarm_arn: "arn:aws:cloudwatch:us-west-2:123456789012:alarm:test",
50-
org_id: "12345",
5150
rule_id: "rule-123",
5251
},
5352
links: {

lambdas/collector/__tests__/utils/test-fixtures.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const testAlertEvents = {
3737
occurred_at: "2025-09-16T12:00:00.000Z",
3838
team: "dev-infra",
3939
identity: {
40-
org_id: "1",
40+
account_id: "1",
4141
rule_id: "test-rule-123",
4242
},
4343
links: {
@@ -59,7 +59,7 @@ export const testAlertEvents = {
5959
occurred_at: "2025-09-16T12:05:00.000Z",
6060
team: "dev-infra",
6161
identity: {
62-
org_id: "1",
62+
account_id: "1",
6363
rule_id: "test-rule-123",
6464
},
6565
links: {
@@ -81,7 +81,7 @@ export const testAlertEvents = {
8181
occurred_at: "2025-09-16T12:00:00.000Z",
8282
team: "platform",
8383
identity: {
84-
org_id: "123456789012",
84+
account_id: "123456789012",
8585
rule_id: "arn:aws:cloudwatch:us-east-1:123456789012:alarm:HighCPU",
8686
},
8787
links: {

lambdas/collector/schemas/README.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ const alert = {
4242
priority: "P1",
4343
occurred_at: "2024-01-15T10:30:00.000Z",
4444
team: "platform-team",
45-
resource: { type: "instance", id: "i-123456" },
46-
identity: { rule_id: "cpu-high" },
45+
identity: { account_id: "123456789012", rule_id: "cpu-high" },
4746
links: { runbook_url: "https://wiki.company.com/cpu-runbook" },
4847
};
4948

@@ -73,8 +72,7 @@ alert = {
7372
"priority": "P1",
7473
"occurred_at": "2024-01-15T10:30:00.000Z",
7574
"team": "platform-team",
76-
"resource": {"type": "instance", "id": "i-123456"},
77-
"identity": {"rule_id": "cpu-high"},
75+
"identity": {"account_id": "123456789012", "rule_id": "cpu-high"},
7876
"links": {"runbook_url": "https://wiki.company.com/cpu-runbook"}
7977
}
8078

@@ -107,8 +105,7 @@ func main() {
107105
"priority": "P1",
108106
"occurred_at": "2024-01-15T10:30:00.000Z",
109107
"team": "platform-team",
110-
"resource": map[string]interface{}{"type": "instance", "id": "i-123456"},
111-
"identity": map[string]interface{}{"rule_id": "cpu-high"},
108+
"identity": map[string]interface{}{"account_id": "123456789012", "rule_id": "cpu-high"},
112109
"links": map[string]interface{}{"runbook_url": "https://wiki.company.com/cpu-runbook"},
113110
}
114111

@@ -152,21 +149,12 @@ func main() {
152149
| `description` | string | Detailed description (max 4000 chars) |
153150
| `summary` | string | High-level summary (max 1000 chars) |
154151
| `reason` | string | Provider-specific reason (max 2000 chars) |
155-
| `resource` | object | Resource information (requires `type` if provided) |
156152
| `raw_provider` | any | Original payload for debugging |
157153

158-
### Resource Types
159-
160-
- `runner` - CI/CD runner or build agent
161-
- `instance` - Virtual machine or container instance
162-
- `job` - Scheduled job or task
163-
- `service` - Application service or microservice
164-
- `generic` - Generic resource type
165-
166154
### Validation Rules
167155

168156
- **URLs**: Must be valid HTTP/HTTPS URLs (max 2048 chars)
169-
- **AWS Account**: Must be 12-digit string
157+
- **Account ID**: Alphanumeric, hyphens, underscores only (max 100 chars)
170158
- **CloudWatch ARN**: Must start with "arn:aws:cloudwatch:"
171159
- **Source/Team**: Alphanumeric, hyphens, underscores only
172160

lambdas/collector/schemas/alert-event.schema.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@
6464
"identity": {
6565
"type": "object",
6666
"properties": {
67-
"aws_account": {
67+
"account_id": {
6868
"type": "string",
69-
"pattern": "^[0-9]{12}$",
70-
"description": "AWS account ID (12 digits)"
69+
"minLength": 1,
70+
"maxLength": 100,
71+
"pattern": "^[a-zA-Z0-9_-]+$",
72+
"description": "Unified account identifier (AWS account ID, organization ID, tenant ID, etc.)"
7173
},
7274
"region": {
7375
"type": "string",
@@ -81,11 +83,6 @@
8183
"pattern": "^arn:aws:cloudwatch:",
8284
"description": "CloudWatch alarm ARN (if applicable)"
8385
},
84-
"org_id": {
85-
"type": "string",
86-
"maxLength": 100,
87-
"description": "Organization ID (for Grafana or other multi-tenant systems)"
88-
},
8986
"rule_id": {
9087
"type": "string",
9188
"maxLength": 255,
@@ -154,7 +151,7 @@
154151
"occurred_at": "2024-01-15T10:30:00.000Z",
155152
"team": "platform-team",
156153
"identity": {
157-
"aws_account": "123456789012",
154+
"account_id": "123456789012",
158155
"region": "us-west-2",
159156
"rule_id": "cpu-high-prod-web"
160157
},

lambdas/collector/src/fingerprint.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function generateCloudWatchFingerprint(alertEvent: AlertEvent): string {
2020
};
2121

2222
// Add CloudWatch-specific identity fields
23-
if (alertEvent.identity.aws_account) {
24-
fingerprintInputs.aws_account = alertEvent.identity.aws_account;
23+
if (alertEvent.identity.account_id) {
24+
fingerprintInputs.account_id = alertEvent.identity.account_id;
2525
}
2626
if (alertEvent.identity.region) {
2727
fingerprintInputs.region = alertEvent.identity.region;
@@ -41,8 +41,8 @@ function generateGrafanaFingerprint(alertEvent: AlertEvent): string {
4141
};
4242

4343
// Add Grafana-specific identity fields
44-
if (alertEvent.identity.org_id) {
45-
fingerprintInputs.org_id = alertEvent.identity.org_id;
44+
if (alertEvent.identity.account_id) {
45+
fingerprintInputs.account_id = alertEvent.identity.account_id;
4646
}
4747
if (alertEvent.identity.rule_id) {
4848
fingerprintInputs.rule_id = alertEvent.identity.rule_id;

lambdas/collector/src/transformers/cloudwatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class CloudWatchTransformer extends BaseTransformer {
7070

7171
// Build identity information
7272
const identity: AlertIdentity = {
73-
aws_account: this.safeString(alarmData.AWSAccountId),
73+
account_id: this.safeString(alarmData.AWSAccountId),
7474
region:
7575
this.extractRegionFromArn(alarmData.AlarmArn) ||
7676
this.normalizeRegion(alarmData.Region || ""),

0 commit comments

Comments
 (0)