{"_id":"@condensetech/cdk-monitoring","_rev":"2-594f84a9c7486c44f305c71ccc3d74af","name":"@condensetech/cdk-monitoring","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@condensetech/cdk-monitoring","version":"0.1.0","keywords":["aws","aws-cdk","cdk","monitoring","cloudwatch","alarms","discord","microsoft-teams","notifications","eventbridge"],"author":{"name":"Condensetech"},"license":"MIT","_id":"@condensetech/cdk-monitoring@0.1.0","maintainers":[{"name":"gawaine","email":"nicola.racco@gmail.com"},{"name":"emaserafini","email":"ema.serafini@gmail.com"}],"homepage":"https://github.com/condensetech/cdk-monitoring#readme","bugs":{"url":"https://github.com/condensetech/cdk-monitoring/issues"},"dist":{"shasum":"e56483a9a58afc33390ab9a5d50e3cb3b3fb5885","tarball":"https://registry.npmjs.org/@condensetech/cdk-monitoring/-/cdk-monitoring-0.1.0.tgz","fileCount":64,"integrity":"sha512-HVqIti8RPISRpBLBRqy9NnVcnRPhBbWjTpxFH/q3yeMDW9IhcP9m6XusQqOx0EYrlXwpG1FsIC/Q5WQx9PtZDw==","signatures":[{"sig":"MEUCIQDlEAN6i/cjzRslzn8GB5qAqWKygIzUVsnvBmZq4pd/4wIgUZdKiiiugP1MLZ7MTAgVq2TBRia6+E6OMqcGdDWYE8A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":141989},"main":"dist/index.js","_from":"file:condensetech-cdk-monitoring-0.1.0.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc && mkdir -p dist/notifications/discord-notifier && cp src/notifications/discord-notifier/*.ts dist/notifications/discord-notifier/","clean":"rm -rf dist","watch":"tsc --watch","typecheck":"tsc --noEmit","preinstall":"npx only-allow pnpm"},"_npmUser":{"name":"emaserafini","email":"ema.serafini@gmail.com"},"_resolved":"/private/var/folders/h6/gj8tnx797k30bfk833snh2d00000gn/T/ee4689e874a98f5d3925f6ef1bba71f8/condensetech-cdk-monitoring-0.1.0.tgz","_integrity":"sha512-HVqIti8RPISRpBLBRqy9NnVcnRPhBbWjTpxFH/q3yeMDW9IhcP9m6XusQqOx0EYrlXwpG1FsIC/Q5WQx9PtZDw==","repository":{"url":"git+https://github.com/condensetech/cdk-monitoring.git","type":"git"},"_npmVersion":"10.9.2","description":"AWS CDK constructs for alarm and notification monitoring: metric alarms via Aspects, severity-based audience routing, Discord + Microsoft Teams notification pipelines, and EventBridge rules for non-metric state changes.","directories":{},"_nodeVersion":"22.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"constructs":"^10.5.0","typescript":"~5.9.3","@types/node":"^22.0.0","aws-cdk-lib":"^2.240.0"},"peerDependencies":{"constructs":"^10.5.0","aws-cdk-lib":"^2.240.0"},"_npmOperationalInternal":{"tmp":"tmp/cdk-monitoring_0.1.0_1776844790870_0.5097810686316866","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@condensetech/cdk-monitoring","version":"0.1.1","description":"AWS CDK constructs for alarm and notification monitoring: metric alarms via Aspects, severity-based audience routing, Discord + Microsoft Teams notification pipelines, and EventBridge rules for non-metric state changes.","main":"dist/index.js","types":"dist/index.d.ts","keywords":["aws","aws-cdk","cdk","monitoring","cloudwatch","alarms","discord","microsoft-teams","notifications","eventbridge"],"author":{"name":"Condensetech"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/condensetech/cdk-monitoring.git"},"homepage":"https://github.com/condensetech/cdk-monitoring#readme","bugs":{"url":"https://github.com/condensetech/cdk-monitoring/issues"},"publishConfig":{"access":"public"},"peerDependencies":{"aws-cdk-lib":"^2.240.0","constructs":"^10.5.0"},"devDependencies":{"@types/node":"^22.0.0","aws-cdk-lib":"^2.240.0","constructs":"^10.5.0","typescript":"~5.9.3"},"scripts":{"preinstall":"npx only-allow pnpm","build":"tsc && mkdir -p dist/notifications/discord-notifier && cp src/notifications/discord-notifier/*.ts dist/notifications/discord-notifier/","watch":"tsc --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@condensetech/cdk-monitoring@0.1.1","_integrity":"sha512-0Q9OvH6tDC0MYS7MBTCAtXVcvLD3B4QMfx1WKlvoPE7BX/3H6Uj01YvFYBFMmjeEHjjnUN76ldXSvNXyHaHx3w==","_resolved":"/private/var/folders/h6/gj8tnx797k30bfk833snh2d00000gn/T/1b983aea7f2f85aa803d6af489e6e211/condensetech-cdk-monitoring-0.1.1.tgz","_from":"file:condensetech-cdk-monitoring-0.1.1.tgz","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-0Q9OvH6tDC0MYS7MBTCAtXVcvLD3B4QMfx1WKlvoPE7BX/3H6Uj01YvFYBFMmjeEHjjnUN76ldXSvNXyHaHx3w==","shasum":"00b54f3a53b144a663b69fe007a762eda02a2339","tarball":"https://registry.npmjs.org/@condensetech/cdk-monitoring/-/cdk-monitoring-0.1.1.tgz","fileCount":64,"unpackedSize":142532,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAfbRA3VQtmBM8Tt98mtpAKcW47I/yNPgptHIlExilRxAiEAxih3U5NewT7mg4B21JYIce3bR+sruexLxznsQBbT3aQ="}]},"_npmUser":{"name":"emaserafini","email":"ema.serafini@gmail.com"},"directories":{},"maintainers":[{"name":"gawaine","email":"nicola.racco@gmail.com"},{"name":"emaserafini","email":"ema.serafini@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cdk-monitoring_0.1.1_1776858455886_0.9756368375924807"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-22T07:59:50.806Z","modified":"2026-04-22T11:47:36.150Z","0.1.0":"2026-04-22T07:59:51.011Z","0.1.1":"2026-04-22T11:47:36.028Z"},"bugs":{"url":"https://github.com/condensetech/cdk-monitoring/issues"},"author":{"name":"Condensetech"},"license":"MIT","homepage":"https://github.com/condensetech/cdk-monitoring#readme","keywords":["aws","aws-cdk","cdk","monitoring","cloudwatch","alarms","discord","microsoft-teams","notifications","eventbridge"],"repository":{"type":"git","url":"git+https://github.com/condensetech/cdk-monitoring.git"},"description":"AWS CDK constructs for alarm and notification monitoring: metric alarms via Aspects, severity-based audience routing, Discord + Microsoft Teams notification pipelines, and EventBridge rules for non-metric state changes.","maintainers":[{"name":"gawaine","email":"nicola.racco@gmail.com"},{"name":"emaserafini","email":"ema.serafini@gmail.com"}],"readme":"# @condensetech/cdk-monitoring\n\nAWS CDK constructs for alarm-driven monitoring and notifications.\n\n- **Metric alarms via CDK Aspects** — automatically discovers Fargate services, ALBs, target groups, ElastiCache clusters, RDS clusters and instances in a stack and attaches alarms with sensible defaults.\n- **Severity-based audience routing** — `warning` alarms go to the dev SNS topic only; `critical` alarms go to both dev and management topics. One subscription per audience (e.g. Discord for dev, Microsoft Teams for management).\n- **Discord + Microsoft Teams pipelines** — ready-made `NotificationStack` with an inline Node.js Lambda that posts CloudWatch alarms and EventBridge events to Discord, plus an optional AWS Chatbot Microsoft Teams configuration.\n- **EventBridge rules for state changes** — helpers for ECS task failures, ECS deployment errors, and RDS cluster events published to the same SNS topics.\n\nThis library is intentionally **alarm-only**: no CloudWatch Dashboards are created. Operators read metrics from the AWS console on demand and act on alarms delivered to chat channels.\n\n## Installation\n\n```bash\npnpm add @condensetech/cdk-monitoring\n```\n\nPeer dependencies: `aws-cdk-lib ^2.240.0`, `constructs ^10.5.0`.\n\n## Quick start\n\n```typescript\nimport { App, Stack } from 'aws-cdk-lib';\nimport {\n  MonitoringFacade,\n  NotificationStack,\n  EventRulesStack,\n} from '@condensetech/cdk-monitoring';\n\nconst app = new App();\n\n// 1. Shared notification pipeline (one per environment).\nconst notifications = new NotificationStack(app, 'MyApp-Dev-Notifications', {\n  namePrefix: 'myapp-dev',\n  discordWebhookSecretName: 'myapp/monitoring/discord-webhook-dev',\n  // teamsChannel: { teamId, tenantId, channelId } // optional\n});\n\n// 2. Attach MonitoringFacade to each application stack you want covered.\nconst appStack = new MyAppStack(app, 'MyApp-Dev-Core', { /* ... */ });\n\nnew MonitoringFacade(appStack, {\n  environmentName: 'myapp-dev',\n  devTopicArn: notifications.devTopic.topicArn,\n  // managementTopicArn: notifications.managementTopic.topicArn,\n});\n\n// 3. Optional: EventBridge rules for non-metric state changes.\nnew EventRulesStack(app, 'MyApp-Dev-EventRules', {\n  devTopic: notifications.devTopic,\n  ecsCluster: appStack.cluster,\n  rdsCluster: appStack.database,\n});\n```\n\n## MonitoringFacade\n\n`MonitoringFacade(scope, props)` registers six CDK Aspects on the given stack. The aspects scan the stack at synth time and create alarms for any resource of a supported type they find:\n\n| Aspect | Resource type | Alarms (default) |\n|---|---|---|\n| FargateServiceMonitoringAspect | `ecs.FargateService` | CPU (Average 90%), Memory (Maximum 90%) |\n| ApplicationLoadBalancerMonitoringAspect | `elbv2.ApplicationLoadBalancer` | RedirectUrlLimit, RejectedConnections, TargetConnectionErrors, Target5xx |\n| TargetGroupMonitoringAspect | `elbv2.ApplicationTargetGroup` | MinHealthyHosts (treat-missing BREACHING) |\n| CacheClusterMonitoringAspect | `elasticache.CfnCacheCluster` | CPU per node, Connections per node, Memory, EngineCPU |\n| RdsClusterMonitoringAspect | `rds.DatabaseCluster` | CPU, ReadLatency, EBS Balance (skipped on Aurora) |\n| RdsInstanceMonitoringAspect | `rds.DatabaseInstance` | CPU, ReadLatency, EBS Balance |\n\nPer-resource overrides are available via `configFargateService()`, `configRdsCluster()`, etc.\n\n### Severity-based routing\n\nEvery alarm carries a `severity` of `warning` (default) or `critical`. The facade wires SNS actions accordingly:\n\n- `warning` → `devTopic` only\n- `critical` → `devTopic` AND `managementTopic` (if provided)\n\nSet `minSeverity: 'critical'` on the facade to skip the creation of warning-level alarms altogether (saves ~$0.10/month per skipped alarm).\n\n### Alarm naming\n\nSet `environmentName` to prepend an env prefix to every alarm name and description, so Discord notifications immediately show which deployment fired the alarm:\n\n```\nALARM: myapp-dev-FargateService-MemoryUtilizationAlarm-core-service\n[myapp-dev] Memory Utilization high on core-service\n```\n\n## NotificationStack\n\nCreates:\n\n- Two SNS topics: `<namePrefix>-dev-notifications` and `<namePrefix>-management-notifications`\n- A Node.js Lambda (`aws-lambda-nodejs`) subscribed to the dev topic that formats CloudWatch alarm and EventBridge event messages as Discord embeds and POSTs to the webhook stored in Secrets Manager\n- An SQS dead-letter queue for the Lambda\n- An AWS Chatbot `MicrosoftTeamsChannelConfiguration` subscribed to the management topic (when `teamsChannel` is provided)\n- SSM parameters `<ssmParameterPrefix>/dev-topic-arn` and `/management-topic-arn` so other repos can look up the topic ARNs via `StringParameter.valueForStringParameter` without CloudFormation cross-stack imports\n\nThe Discord webhook Secrets Manager secret must be created separately (the stack references it by name). Value can be a plain URL or `{\"url\": \"...\"}` JSON.\n\n## EventRulesStack\n\nHelpers and a ready-made stack for EventBridge rules that publish non-metric events to the same SNS pipeline:\n\n- `addEcsTaskFailureRule(scope, id, { cluster, devTopic, ... })` — ECS task STOPPED with a stop code other than normal scheduler/user stops\n- `addEcsDeploymentFailureRule(scope, id, { cluster, devTopic, ... })` — ECS deployment `eventType=ERROR`\n- `addRdsClusterEventRule(scope, id, { cluster, devTopic, ... })` — RDS cluster `failover`, `failure`, `maintenance` events\n\n## License\n\nMIT — see [LICENSE](./LICENSE).\n","readmeFilename":"README.md"}