Group
  • Deployment

    Set log retention so old logs don't cost more than the app

    Configure log retention and sampling so you keep what matters and don't pay to store noise forever.

    • Improve quality
    • Plan & validate
    • Beginner
    • General

Free Prompt

Configure log retention and sampling for my app. Most log providers meter by ingestion and storage volume, and default settings will happily bill you for terabytes of debug logs nobody reads. Do the following: 1. Set retention windows by log type: short (7-14 days) for high-volume info/debug logs, longer (30-90 days) for warn/error and audit-relevant logs. Anything required by compliance goes into a separate archive tier with the mandated retention. 2. Sample high-volume logs: if I'm logging every request, sample at 10% for successes and 100% for errors. Same for third-party API calls or hot code paths. Don't sample audit events. 3. Cut noise at the source: level-check before formatting expensive log messages, silence chatty libraries that log 'connected' every 30 seconds, and stop logging the same thing at multiple levels. 4. Never log secrets, tokens, or full request bodies. Add filters at the logger level so PII scrubbing doesn't rely on remembering. 5. Audit-relevant events (auth, permission changes, admin actions, payments) get logged separately from operational logs, with longer retention and stricter access. These are the logs you'll need in a security incident and don't want mixed into the firehose. 6. Cost check: look at current log volume and estimated monthly cost. Flag the top three noisy sources; often 80% of the volume is one bad log line. Don't cut error retention to save money. The deliverable is retention configured per log type, sampling in place on high-volume paths, noisy sources trimmed, audit logs isolated, and a documented monthly cost estimate.

What This Does / How This Helps

This tunes log retention and sampling per category: short windows and sampling for noise, long retention for errors and audits, and a fix for the one library that's producing half your log bill. The default 'keep everything forever' setup turns into a surprise invoice about two months after launch, and worse, makes searching slow because you're grepping through 90 days of health-check pings. Sampling and per-category retention keep the logs useful and the bill sane.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts