Azure Sentinel

Azure Sentinel

LiteLLM은 Azure Monitor Logs Ingestion API를 통해 Azure Sentinel로 로깅을 지원해요. Azure Sentinel은 데이터 저장에 Log Analytics 작업 영역을 사용하므로, 작업 영역으로 보낸 로그는 보안 모니터링과 분석을 위해 Sentinel에서도 사용할 수 있어요.

출처: 문서

본문

Azure Sentinel 통합 (Azure Sentinel Integration)

기능 세부
로깅되는 것 StandardLoggingPayload
이벤트 성공 + 실패
제품 링크 Azure Sentinel
API 참조 Logs Ingestion API

--configlitellm.callbacks = ["azure_sentinel"]을 설정하면 모든 성공·실패 LLM 호출이 Azure Sentinel에 로깅돼요.

1단계: config.yaml 파일을 만들고 litellm_settings: callbacks 설정

config.yaml:

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

2단계: Azure 리소스 설정

Logs Ingestion API를 사용하기 전에 Azure에서 다음을 설정해야 해요.

  1. Log Analytics 작업 영역 생성(없는 경우)
  2. Log Analytics 작업 영역에 사용자 지정 테이블(Custom Table) 생성(예: LiteLLM_CL)
  3. 다음을 포함한 DCR(Data Collection Rule) 생성:
    • 데이터 구조와 일치하는 스트림 선언
    • 사용자 지정 테이블로 데이터를 매핑하는 변환
    • 앱 등록에 부여된 접근 권한
  4. 다음을 가진 애플리케이션 등록을 Microsoft Entra ID(Azure AD)에 생성:
    • 클라이언트 ID
    • 클라이언트 시크릿
    • DCR에 쓸 권한

자세한 설정 지침은 Microsoft Logs Ingestion API 문서를 참고해 주세요.

3단계: 필수 환경 변수 설정

Azure 자격 증명으로 다음 환경 변수를 설정해 주세요.

# 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 (NOT the DCE endpoint)

# 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

참고: AZURE_SENTINEL_ENDPOINT는 DCR의 로그 수집 엔드포인트(DCR Overview 페이지에서 확인)여야 하며, DCE(Data Collection Endpoint)가 아니에요. DCR 엔드포인트는 특정 DCR과 연결되며 https://your-dcr-endpoint.{region}-1.ingest.monitor.azure.com처럼 생겼어요.

4단계: 프록시를 시작하고 테스트 요청 보내기

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

5단계: Azure Sentinel에서 로그 보기

  1. Azure 포털에서 Azure Sentinel 작업 영역으로 이동
  2. "Logs"로 가서 사용자 지정 테이블(예: LiteLLM_CL) 쿼리
  3. 다음과 같은 쿼리 실행:

KQL Query:

LiteLLM_CL
| where TimeGenerated > ago(1h)
| project TimeGenerated, model, status, total_tokens, response_cost
| order by TimeGenerated desc

환경 변수 (Environment Variables)

환경 변수 설명 기본값 필수
AZURE_SENTINEL_DCR_IMMUTABLE_ID Data Collection Rule (DCR) Immutable ID 없음 ✅ 예
AZURE_SENTINEL_ENDPOINT DCR 로그 수집 엔드포인트 URL(DCR Overview 페이지에서) 없음 ✅ 예
AZURE_SENTINEL_STREAM_NAME DCR의 스트림 이름(예: "Custom-LiteLLM_CL_CL") "Custom-LiteLLM" ❌ 아니오
AZURE_SENTINEL_TENANT_ID OAuth2 인증용 Azure Tenant ID 없음(AZURE_TENANT_ID로 폴백) ✅ 예
AZURE_SENTINEL_CLIENT_ID OAuth2 인증용 Application(client) ID 없음(AZURE_CLIENT_ID로 폴백) ✅ 예
AZURE_SENTINEL_CLIENT_SECRET OAuth2 인증용 클라이언트 시크릿 없음(AZURE_CLIENT_SECRET로 폴백) ✅ 예
AZURE_SENTINEL_AUTHORITY_HOST OAuth2 토큰을 발급하는 Microsoft Entra 권한 호스트 없음(AZURE_AUTHORITY_HOST로 폴백, 이후 https://login.microsoftonline.com) ❌ 아니오

소버린 클라우드 (Sovereign clouds)

Azure Government는 자체 Entra 권한과 자체 Azure Monitor 대상(audience)을 사용하므로, AZURE_SENTINEL_ENDPOINT만 소버린 수집 엔드포인트로 가리키는 것만으로는 부족해요. 권한 호스트를 설정하면 LiteLLM이 일치하는 대상을 파생시켜요:

클라우드 권한 호스트 파생 대상(audience)
Azure Public Cloud(기본값) https://login.microsoftonline.com https://monitor.azure.com/.default
Azure Government https://login.microsoftonline.us https://monitor.azure.us/.default

AZURE_AUTHORITY_HOSTazure_storage 콜백과 Azure OpenAI OIDC와 공유되므로 설정하면 그들도 같은 클라우드로 이동해요. Sentinel 작업 영역이 나머지 Azure 리소스와 다른 클라우드에 있다면 AZURE_SENTINEL_AUTHORITY_HOST를 사용하세요. 이 값은 Sentinel에만 우선 적용돼요. 둘 다 콜백이 처음 사용될 때 읽히므로 변경을 적용하려면 프록시를 다시 시작해야 해요.

동작 방식 (How It Works)

Azure Sentinel 통합은 Azure Monitor Logs Ingestion API를 사용해 Log Analytics 작업 영역으로 로그를 보내요. 이 통합은:

  • 앱 등록으로 OAuth2 클라이언트 자격 증명 흐름으로 인증
  • Data Collection Rule (DCR) 엔드포인트로 로그 전송
  • 효율적 전송을 위해 로그 배칭
  • StandardLoggingPayload 형식으로 로그 전송
  • 성공·실패 이벤트를 모두 자동 처리
  • OAuth2 토큰 캐시 및 자동 갱신

Log Analytics 작업 영역으로 보낸 로그는 보안 모니터링, 위협 탐지, 분석을 위해 Azure Sentinel에서 자동으로 사용할 수 있어요.

Azure Sentinel 설정 가이드 (Azure Sentinel Setup Guide)

LiteLLM과 함께 Azure Sentinel을 설정하는 단계별 가이드예요.

1단계: Log Analytics 작업 영역 생성

  1. https://portal.azure.com/#home으로 이동
  2. "Log Analytics workspaces" 검색 후 "Create" 클릭
  3. 작업 영역 이름 입력(예: "litellm-sentinel-prod")
  4. "Review + Create" 클릭

2단계: 사용자 지정 테이블 생성

  1. Log Analytics 작업 영역으로 가서 "Tables" 클릭
  2. "Create" → "New custom log (Direct Ingest)" 클릭
  3. 테이블 이름 입력(예: "LITELLM_PROD_CL")

3단계: DCR(Data Collection Rule) 생성

  1. "Create a new data collection rule" 클릭
  2. DCR 이름 입력(예: "litellm-prod")
  3. Data Collection Endpoint 선택
  4. 스키마용 샘플 JSON 파일 업로드(example_standard_logging_payload.json 사용)
  5. "Next" → "Create" 클릭

4단계: DCR Immutable ID와 로그 수집 엔드포인트 가져오기

  1. "Data Collection Rules"로 가서 DCR 선택
  2. DCR Immutable ID 복사(dcr-로 시작)
  3. Logs Ingestion Endpoint URL 복사

5단계: 스트림 이름 가져오기

  1. DCR에서 "JSON View" 클릭
  2. streamDeclarations 섹션에서 Stream Name 찾기(예: "Custom-LITELLM_PROD_CL_CL")

6단계: 앱 등록 및 권한 부여

  1. Microsoft Entra IDApp registrationsNew registration으로 이동
  2. 새 앱을 만들고 Client IDTenant ID 기록
  3. Certificates & secrets → 새 클라이언트 시크릿 생성, Secret Value 복사
  4. DCR로 돌아가 Access Control (IAM)Add role assignment
  5. 앱 등록에 "Monitoring Metrics Publisher" 역할 할당

각 값의 위치 요약 (Summary: Where to Find Each Value)

환경 변수 찾는 곳
AZURE_SENTINEL_DCR_IMMUTABLE_ID DCR Overview 페이지 → Immutable ID(dcr-로 시작)
AZURE_SENTINEL_ENDPOINT DCR Overview 페이지 → Logs Ingestion Endpoint
AZURE_SENTINEL_STREAM_NAME DCR JSON View → streamDeclarations 섹션
AZURE_SENTINEL_TENANT_ID App Registration → Overview → Directory (tenant) ID
AZURE_SENTINEL_CLIENT_ID App Registration → Overview → Application (client) ID
AZURE_SENTINEL_CLIENT_SECRET App Registration → Certificates & secrets → Secret Value

자세한 내용은 Microsoft Logs Ingestion API 문서를 참고해 주세요.

더 알아보기 (Learn more)