feat(proxy)!: default audit logs on for enterprise licenses - #37518
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThe PR makes audit logging tri-state and enables it by default for premium deployments while preserving explicit configuration and environment overrides.
Confidence Score: 5/5The PR appears safe to merge. The previously reported plaintext-key concern was withdrawn correctly because audit models mask key fields before both database and callback sinks, and no blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/management_helpers/audit_logs.py | Adds the centralized config/environment/license resolver and applies it before audit persistence and callback dispatch. |
| litellm/proxy/hooks/key_management_event_hooks.py | Routes key lifecycle auditing through the resolver; generated key fields are masked before reaching audit sinks. |
| litellm/proxy/proxy_server.py | Uses resolved audit enablement when reporting callback initialization without changing callback registration. |
| tests/test_litellm/proxy/management_helpers/test_audit_log_callbacks.py | Covers resolver precedence, premium defaults, explicit opt-out, and non-premium persistence behavior. |
Reviews (3): Last reviewed commit: "test(proxy): disable audit logging for k..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai review latest head |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 25de920. Configure here.
|
@greptileai the plaintext-key concern was withdrawn in thread, please re-review so the summary score reflects the current head |
3a04860
into
litellm_internal_staging
TLDR
Problem this solves:
LITELLM_STORE_AUDIT_LOGSwas ignored by the key hooksHow it solves it:
store_audit_logsis now tri-state, unset means autostore_audit_logs: falsestays a hard opt-outUser Flow
Before: an admin running an enterprise license creates a virtual key, then finds the audit trail empty because a setting they never knew about was missing
store_audit_logsin the configkey_alias, and get back 200 with a newsk-key{"audit_logs": [], "total": 0}store_audit_logs: true, add it, and restartAfter: the same admin gets the audit trail without configuring anything, and can still turn it off
store_audit_logsin the configsk-key"action": "created", the key id, and the admin who created it, with the key value itself maskedstore_audit_logs: falseunderlitellm_settingsand restart, and keys created after that are recorded nowhereAdmins without an enterprise license see no change, since audit entries were already refused for them and unset still means off.
Relevant issues
Linear ticket
Resolves LIT-5847
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: one proxy on localhost:4000 against postgres, started the same way for every case with a real enterprise license in
LITELLM_LICENSE, usinglitellm/proxy/dev_config.yaml, which carries nostore_audit_logsand noaudit_log_callbacks. The opt-out case uses a copy of that config withlitellm_settings.store_audit_logs: falseadded. API responses below are trimmed to the fields that matter, and the UI screenshots come from a separate run with the audit table truncated first, where theUpdated/Usersrow is written by the Admin UI login itself, not by the key creationsThe two totals in the After section count rows left in the same postgres by earlier runs, so the signal is which
object_idvalues are present, not the count itselfBefore (a1afc2f)
Default, no store_audit_logs
Explicit store_audit_logs false
After (25de920)
Default, no store_audit_logs
ui-audit-default-onin the Admin UI puts aCreated/Keysrow on http://localhost:4000/ui/logs/auditkeyandkey_namemaskedkey_aliasmasked tooExplicit store_audit_logs false
store_audit_logs: falseand create another key on the same enterprise licenseui-audit-optout-should-not-logadds no rowNo license
ui-audit-no-licenseadds no row eitherType
🆕 New Feature
Caveats (if any)
LiteLLM_AuditLoghas no index beyond its primary key and no retention job, and GET /audit sorts byupdated_atwith a full count, so turning this on by default makes that growth common. Tracked in LIT-5848 rather than hereFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/e80aa2b7e845458f8a7a5c09bf013abe
Requested by: @yucheng-berri