fix(azure_sentinel): resolve audit stream from AZURE_SENTINEL_AUDIT_STREAM_NAME - #32010
Conversation
Greptile SummaryThis PR fixes a one-line bug in
Confidence Score: 5/5Safe to merge — the change is a single-line addition that fills a missing env-var lookup, matches the existing resolution pattern used for every other Azure Sentinel config parameter, and is covered by a new mock test. The fix is minimal and isolated: one new os.getenv call inserted into an already-established fallback chain inside init. No logic is removed or restructured, no other callers are affected, and the new test exercises both the env-var path and the explicit-argument override path without making real network calls. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/integrations/azure_sentinel/azure_sentinel.py | Adds os.getenv("AZURE_SENTINEL_AUDIT_STREAM_NAME") as a fallback in the audit stream resolution chain, mirroring the existing pattern used for the standard stream — minimal, correct one-liner fix. |
| tests/test_litellm/integrations/test_azure_sentinel.py | Adds a focused mock-only test that uses monkeypatch.setenv to validate both env-var resolution and explicit-argument override — no real network calls, assertions cover the exact endpoints that were broken. |
Reviews (2): Last reviewed commit: "fix(azure_sentinel): resolve audit strea..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…TREAM_NAME When AzureSentinelLogger is resolved from the string callback name "azure_sentinel", it is constructed with no arguments, so audit_stream_name is always None and resolved_audit_stream_name fell back to the standard resolved_stream_name. Audit logs then ingested into the access-log DCR stream whose schema is built from StandardLoggingPayload, so Azure Monitor Logs Ingestion silently dropped the audit-specific columns and audit rows arrived effectively empty. Add an AZURE_SENTINEL_AUDIT_STREAM_NAME env var fallback in __init__, mirroring the AZURE_SENTINEL_STREAM_NAME idiom already used for the standard stream, so audit logs can target a separate DCR stream without a custom callbacks file.
4e9a9f8 to
460600c
Compare
|
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 460600c. Configure here.
93cdcca
into
litellm_internal_staging
Relevant issues
Linear ticket
Resolves LIT-4174
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
AzureSentinelLoggeralready supports anaudit_stream_nameso audit logs can target a separate DCR stream, but when the logger is resolved from the string callback nameazure_sentinelit is constructed with no arguments, soaudit_stream_namewas alwaysNoneand fell back to the standardAZURE_SENTINEL_STREAM_NAME. Audit events then land on the access-log DCR stream, whose schema is built fromStandardLoggingPayload, and Azure Monitor Logs Ingestion silently drops the undeclared audit columns, so audit rows arrive with onlyTimeGenerated.This was verified end to end against a real Azure Monitor Logs Ingestion workspace: a real Data Collection Endpoint, one Data Collection Rule with two streams (an access-log stream
Custom-LiteLLM_CLand a dedicated audit streamCustom-LiteLLM_Audit_CL, each mapped to its own custom table), and a service principal granted Monitoring Metrics Publisher on the DCR. A live proxy was run with the ticket's config, a real admin action created a real audit log, and the rows were queried back from the workspace. Audit-log generation is an enterprise feature so the license check was satisfied for the run; theAzureSentinelLoggercode under test is unmodified.Config (the exact setup from the ticket):
Trigger (a real admin action that produces a real audit log):
Before the fix, with
AZURE_SENTINEL_AUDIT_STREAM_NAMEset, the audit event ingests into the access-log tableLiteLLM_CL, which has no audit columns, so everything exceptTimeGeneratedis dropped:After the fix, the same action with the same environment ingests into the dedicated audit table
LiteLLM_Audit_CLwith every audit column populated:The
object_idvalues are the team IDs returned by the create-team calls, confirming these rows are the events those requests produced. Live proxy log for one flush:Azure Sentinel - about to flush 1 audit logsthenAzure Sentinel: Response from API status_code: 204.The standard access-log endpoint is unchanged;
api_endpointandaudit_api_endpointare built independently in__init__, so the fix only affects the audit streamType
🐛 Bug Fix
Changes
AzureSentinelLogger.__init__now resolves the audit stream asaudit_stream_name or os.getenv("AZURE_SENTINEL_AUDIT_STREAM_NAME") or resolved_stream_name, mirroring theAZURE_SENTINEL_STREAM_NAMEfallback already used for the standard stream. Because every string-callback construction site (_init_custom_logger_compatible_classfor bothcallbacksandaudit_log_callbacks) builds the logger with no arguments, this single change lets audit logs target a separate DCR stream without a custom callbacks file. A regression test constructs the logger with noaudit_stream_nameand only the env var set, and asserts the resolved audit endpoint uses the env var stream while the standard endpoint keeps the access-log streamCI note
The
AZURE_SENTINEL_AUDIT_STREAM_NAMEenv var is documented in the separate env-settings reference via BerriAI/litellm-docs#477 (merged), which thedocumentationandcode-qualitychecks validateNote
Low Risk
Narrow logging-callback configuration fix with tests; no auth or core proxy request-path changes.
Overview
Fixes audit logs being ingested into the standard DCR stream when the proxy registers
azure_sentinelas a string callback with no constructor args.AzureSentinelLoggernow resolves the audit stream asaudit_stream_name→AZURE_SENTINEL_AUDIT_STREAM_NAME→ standard stream (same pattern asAZURE_SENTINEL_STREAM_NAME). That updatesaudit_api_endpointonly; access-log ingestion is unchanged. Docstring reflects the new env var.A regression test asserts env-based resolution splits audit vs standard endpoints, and that an explicit
audit_stream_namestill overrides the env var.Reviewed by Cursor Bugbot for commit 460600c. Bugbot is set up for automated code reviews on this repo. Configure here.