feat(observability): prompt-cache CloudWatch dashboard + alarms#699
Merged
Conversation
follow-up) New cross-service construct area lib/constructs/observability/ with a PromptCacheObservabilityConstruct composed into PlatformStack. Graphs the dimension-less EMF metrics both APIs emit into AgentCoreStack/PromptCache (cache read/write tokens, a cache-efficiency MathExpression, AvoidableMiss, WastedUsd) plus a Logs Insights widget over the runtime log group grouped by cacheStatus. Console-only alarms on AvoidableMiss and WastedUsd Sums (stricter in prod, NOT_BREACHING on missing data so the PROMPT_CACHE_OBSERVABILITY_ENABLED kill switch stays quiet). No SNS — alerting infra is deliberately out of scope, matching kb-sync and scheduled-runs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up #1 from #697 (deliberately excluded there to keep it backend-only): CDK dashboard + alarms for the prompt-cache EMF metrics already emitting in prod from
backend/src/apis/shared/observability/emf.py.infrastructure/lib/constructs/observability/withPromptCacheObservabilityConstruct, composed intoPlatformStack(metric-namespace-based — no typed refs needed).{prefix}-prompt-cache-observabilityover theAgentCoreStack/PromptCachenamespace:MathExpression—100 * reads / (reads + writes)cacheStatusEMF log propertyAvoidableMissSum — the alarm target nominated in emf.py — >10 (prod) / >50 (dev) per 5-min period, 3 evaluation periodsWastedUsdSum — >$1 (prod) / >$5 (dev) per 5-min period, 3 evaluation periodsTreatMissingData.NOT_BREACHINGso thePROMPT_CACHE_OBSERVABILITY_ENABLED=falsekill switch (or zero traffic) never pagesThe per-session drill-down counterpart to this fleet view is
GET /admin/costs/sessions/{id}/calls.Verification
npx tsc --noEmitcleannpx jest— 475 tests / 24 suites passnpx cdk synthclean; dashboard + both alarms confirmed in the synthesized templateDeploys via platform.yml (CDK).
🤖 Generated with Claude Code