Skip to content

feat(observability): prompt-cache CloudWatch dashboard + alarms#699

Merged
philmerrell merged 1 commit into
developfrom
feature/prompt-cache-dashboard
Jul 20, 2026
Merged

feat(observability): prompt-cache CloudWatch dashboard + alarms#699
philmerrell merged 1 commit into
developfrom
feature/prompt-cache-dashboard

Conversation

@philmerrell

Copy link
Copy Markdown
Contributor

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.

  • New cross-service construct area infrastructure/lib/constructs/observability/ with PromptCacheObservabilityConstruct, composed into PlatformStack (metric-namespace-based — no typed refs needed).
  • Dashboard {prefix}-prompt-cache-observability over the AgentCoreStack/PromptCache namespace:
    • Cache read vs write tokens (Sum)
    • Cache efficiency as a MathExpression100 * reads / (reads + writes)
    • AvoidableMiss and WastedUsd sums
    • Logs Insights widget over the AgentCore Runtime log group grouped by the cacheStatus EMF log property
  • Alarms (console-only — no SNS topics exist in the stack yet, same posture as kb-sync/scheduled-runs):
    • AvoidableMiss Sum — the alarm target nominated in emf.py — >10 (prod) / >50 (dev) per 5-min period, 3 evaluation periods
    • WastedUsd Sum — >$1 (prod) / >$5 (dev) per 5-min period, 3 evaluation periods
    • Both TreatMissingData.NOT_BREACHING so the PROMPT_CACHE_OBSERVABILITY_ENABLED=false kill switch (or zero traffic) never pages
  • CfnOutput for the dashboard name.
  • Unit tests: dashboard body coverage, alarm count/thresholds/missing-data posture, prod-vs-dev thresholds, export name.

The per-session drill-down counterpart to this fleet view is GET /admin/costs/sessions/{id}/calls.

Verification

  • npx tsc --noEmit clean
  • npx jest — 475 tests / 24 suites pass
  • npx cdk synth clean; dashboard + both alarms confirmed in the synthesized template

Deploys via platform.yml (CDK).

🤖 Generated with Claude Code

 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>
@philmerrell
philmerrell merged commit 06d4351 into develop Jul 20, 2026
4 checks passed
@philmerrell
philmerrell deleted the feature/prompt-cache-dashboard branch July 20, 2026 13:14
@philmerrell philmerrell mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant