Skip to main content

Azure Sentinel

LiteLLM supports logging to Azure Sentinel via the Azure Monitor Logs Ingestion API. Azure Sentinel uses Log Analytics workspaces for data storage, so logs sent to the workspace will be available in Sentinel for security monitoring and analysis.

Azure Sentinel Integration​

FeatureDetails
What is loggedStandardLoggingPayload
EventsSuccess + Failure
Product LinkAzure Sentinel
API ReferenceLogs Ingestion API

We will use the --config to set litellm.callbacks = ["azure_sentinel"] this will log all successful and failed LLM calls to Azure Sentinel.

Step 1: Create a config.yaml file and set litellm_settings: callbacks

config.yaml
model_list:
- model_name: gpt-6-luna
litellm_params:
model: gpt-6-luna
litellm_settings:
callbacks: ["azure_sentinel"] # logs llm success + failure logs to Azure Sentinel

Step 2: Set Up Azure Resources

Before using the Logs Ingestion API, you need to set up the following in Azure:

  1. Create a Log Analytics Workspace (if you don't have one)
  2. Create a Custom Table in your Log Analytics workspace (e.g., LiteLLM_CL)
  3. Create a Data Collection Rule (DCR) with:
    • Stream declaration matching your data structure
    • Transformation to map data to your custom table
    • Access granted to your app registration
  4. Register an Application in Microsoft Entra ID (Azure AD) with:
    • Client ID
    • Client Secret
    • Permissions to write to the DCR

For detailed setup instructions, see the Microsoft documentation on Logs Ingestion API.

Step 3: Set Required Environment Variables

Set the following environment variables with your Azure credentials:

Environment Variables
# Required: Data Collection Rule (DCR) configuration
AZURE_SENTINEL_DCR_IMMUTABLE_ID="dcr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # DCR Immutable ID from Azure portal
AZURE_SENTINEL_STREAM_NAME="Custom-LiteLLM_CL_CL" # Stream name from your DCR
AZURE_SENTINEL_ENDPOINT="https://your-dcr-endpoint.eastus-1.ingest.monitor.azure.com" # DCR logs ingestion endpoint or DCE logs ingestion URI

# Required: OAuth2 Authentication (App Registration)
AZURE_SENTINEL_TENANT_ID="your-tenant-id" # Azure Tenant ID
AZURE_SENTINEL_CLIENT_ID="your-client-id" # Application (client) ID
AZURE_SENTINEL_CLIENT_SECRET="your-client-secret" # Client secret value

Note: AZURE_SENTINEL_ENDPOINT can be either the DCR's logs ingestion endpoint (DCR Overview page) or the logs ingestion URI of a Data Collection Endpoint (DCE) linked to your DCR (DCE Overview page). Both look like https://<name>.{region}-1.ingest.monitor.azure.com. The Logs Ingestion API accepts either one, so use the DCE URI if a Microsoft Sentinel connector gave you one.

A DCR created for direct ingestion ("kind": "Direct") has its own logs ingestion endpoint, shown on the DCR Overview page and in the DCR JSON view under properties.endpoints.logsIngestion. To use a DCE instead, open Monitor → Data Collection Endpoints, select the DCE your DCR is linked to (the DCR's dataCollectionEndpointId), and copy Logs Ingestion from its Overview page. You need a DCE when the workspace uses private link or the DCR has no logs ingestion endpoint of its own, which is the case for DCRs created before March 31, 2024 or without "kind": "Direct". The DCE, DCR and Log Analytics workspace must be in the same region.

Step 4: Start the proxy and make a test request

Start proxy

Start Proxy
litellm --config config.yaml --debug

Test Request

Test Request
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-6-luna",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
],
"metadata": {
"your-custom-metadata": "custom-field",
}
}'

Step 5: View logs in Azure Sentinel

  1. Navigate to your Azure Sentinel workspace in the Azure portal
  2. Go to "Logs" and query your custom table (e.g., LiteLLM_CL)
  3. Run a query like:
KQL Query
LiteLLM_CL
| where TimeGenerated > ago(1h)
| project TimeGenerated, model, status, total_tokens, response_cost
| order by TimeGenerated desc

You should see following logs in Azure Workspace.

Environment Variables​

Environment VariableDescriptionDefault ValueRequired
AZURE_SENTINEL_DCR_IMMUTABLE_IDData Collection Rule (DCR) Immutable IDNone✅ Yes
AZURE_SENTINEL_ENDPOINTDCR logs ingestion endpoint or DCE logs ingestion URINone✅ Yes
AZURE_SENTINEL_STREAM_NAMEStream name from DCR (e.g., "Custom-LiteLLM_CL_CL")"Custom-LiteLLM"❌ No
AZURE_SENTINEL_TENANT_IDAzure Tenant ID for OAuth2 authenticationNone (falls back to AZURE_TENANT_ID)✅ Yes
AZURE_SENTINEL_CLIENT_IDApplication (client) ID for OAuth2 authenticationNone (falls back to AZURE_CLIENT_ID)✅ Yes
AZURE_SENTINEL_CLIENT_SECRETClient secret for OAuth2 authenticationNone (falls back to AZURE_CLIENT_SECRET)✅ Yes
AZURE_SENTINEL_AUTHORITY_HOSTMicrosoft Entra authority host that issues the OAuth2 tokenNone (falls back to AZURE_AUTHORITY_HOST, then https://login.microsoftonline.com)❌ No

Sovereign clouds​

Azure Government uses its own Entra authority and its own Azure Monitor audience, so pointing AZURE_SENTINEL_ENDPOINT at a sovereign ingestion endpoint is not enough on its own. Set the authority host and LiteLLM derives the matching audience:

CloudAuthority hostDerived audience
Azure Public Cloud (default)https://login.microsoftonline.comhttps://monitor.azure.com/.default
Azure Governmenthttps://login.microsoftonline.ushttps://monitor.azure.us/.default

AZURE_AUTHORITY_HOST is shared with the azure_storage callback and Azure OpenAI OIDC, so setting it moves those to the same cloud. Use AZURE_SENTINEL_AUTHORITY_HOST when your Sentinel workspace lives in a different cloud than the rest of your Azure resources; it takes precedence for Sentinel only. Both are read when the callback is first used, so restart the proxy to apply a change

How It Works​

The Azure Sentinel integration uses the Azure Monitor Logs Ingestion API to send logs to your Log Analytics workspace. The integration:

  • Authenticates using OAuth2 client credentials flow with your app registration
  • Sends logs to your Data Collection Rule (DCR) through its logs ingestion endpoint or a linked Data Collection Endpoint (DCE)
  • Batches logs for efficient transmission
  • Sends logs in the StandardLoggingPayload format
  • Automatically handles both success and failure events
  • Caches OAuth2 tokens and refreshes them automatically

Logs sent to the Log Analytics workspace are automatically available in Azure Sentinel for security monitoring, threat detection, and analysis.

Azure Sentinel Setup Guide​

Follow this step-by-step guide to set up Azure Sentinel with LiteLLM.

Step 1: Create a Log Analytics Workspace​

  1. Navigate to https://portal.azure.com/#home

  1. Search for "Log Analytics workspaces" and click "Create"

  1. Enter a name for your workspace (e.g., "litellm-sentinel-prod")

  1. Click "Review + Create"

Step 2: Create a Custom Table​

  1. Go to your Log Analytics workspace and click "Tables"

  1. Click "Create" → "New custom log (Direct Ingest)"

  1. Enter a table name (e.g., "LITELLM_PROD_CL")

Step 3: Create a Data Collection Rule (DCR)​

  1. Click "Create a new data collection rule"

  1. Enter a name for the DCR (e.g., "litellm-prod")

  1. Select a Data Collection Endpoint

  1. Upload the sample JSON file for schema (use the example_standard_logging_payload.json file)

  1. Click "Next" and then "Create"

Step 4: Get the DCR Immutable ID and Logs Ingestion Endpoint​

  1. Go to "Data Collection Rules" and select your DCR

  1. Copy the DCR Immutable ID (starts with dcr-)

  1. Copy the Logs Ingestion Endpoint URL. If you would rather send through the Data Collection Endpoint you selected in Step 3, copy Logs Ingestion from that DCE's Overview page under Monitor → Data Collection Endpoints. Either URL works as AZURE_SENTINEL_ENDPOINT.

Step 5: Get the Stream Name​

  1. Click "JSON View" in the DCR

  1. Find the Stream Name in the streamDeclarations section (e.g., "Custom-LITELLM_PROD_CL_CL")

Step 6: Register an App and Grant Permissions​

  1. Go to Microsoft Entra ID → App registrations → New registration
  2. Create a new app and note the Client ID and Tenant ID
  3. Go to Certificates & secrets → Create a new client secret and copy the Secret Value
  4. Go back to your DCR → Access Control (IAM) → Add role assignment
  5. Assign the "Monitoring Metrics Publisher" role to your app registration

Summary: Where to Find Each Value​

Environment VariableWhere to Find It
AZURE_SENTINEL_DCR_IMMUTABLE_IDDCR Overview page → Immutable ID (starts with dcr-)
AZURE_SENTINEL_ENDPOINTDCR Overview page → Logs Ingestion Endpoint, or DCE Overview page → Logs Ingestion
AZURE_SENTINEL_STREAM_NAMEDCR JSON View → streamDeclarations section
AZURE_SENTINEL_TENANT_IDApp Registration → Overview → Directory (tenant) ID
AZURE_SENTINEL_CLIENT_IDApp Registration → Overview → Application (client) ID
AZURE_SENTINEL_CLIENT_SECRETApp Registration → Certificates & secrets → Secret Value

For more details, refer to the Microsoft Logs Ingestion API documentation.