# microsoft/log_analyzer architecture

> Architecture diagram of the GitHub repository microsoft/log_analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/log_analyzer
- Repository: https://github.com/microsoft/log_analyzer

## Overview

##### Project type and purpose
- This is an open-source CLI tool (“Log Analyzer”) written in Python for server/hardware debugging.
- Its primary purpose is to ingest various log formats, apply AI-powered analysis (via a local LLM), compare against “good” baseline logs, detect error signatures, optionally query Azure DevOps, and emit textual/HTML reports.

##### File structure
- Top-level files:
- log_analyzer/log_analyzer.py – the main entry point and orchestrator
- common/lib_log.py – core analysis engine (signature matching, LLM integration, diff logic)
- common/llm_config.json – local LLM configuration (model, endpoint, timeouts)
- sut/settings.sample.json – template for error-signature configs (per signature JSON under sut/)
- requirements.txt – Python dependencies
- Directories for extensibility:
- tools/SEL/ – user-provided BMC SEL decoder hooks
- tools/GB_CPER_Decoder/ – user-provided CPER decoder hooks
- Configurable external integrations:
- Local LLM service (e.g., Ollama, vLLM)
- Azure DevOps (ADO) via REST/API

##### README for additional insights
- Describes the 4-stage workflow: Initialize → Pre-process → Analyze → Post-process
- Key components: CLI orchestrator, analysis engine (lib_log), signature configs, decoder hooks, report generators
- Lists output artifacts: .log, .html, CSV, diff files

##### Elements
- Clear labels for each module (e.g., “Pre-processor”, “Analysis Engine”)
- Green for config files & JSONs
- Orange for external services (LLM, ADO)

- Layer 1: User invokes CLI with flags
- Layer 3: Pre-processor (CSV conversion, decoder hooks)
- Layer 4: Analysis engine (signature matcher, diff, LLM integration)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Layer 1: CLI Invocation"
        CLI["User CLI\n(python log_analyzer.py)"]:::core
    end

    subgraph "Layer 2: Configuration Loader"
        LLMConfig["LLM Config\n(common/llm_config.json)"]:::config
        SigConfig["Signature Template\n(sut/settings.sample.json)"]:::config
        Version["CLI Version Metadata\n(log_analyzer/version.txt)"]:::config
        README["Project README\n(README.md)"]:::config
        Req["Dependencies\n(requirements.txt)"]:::config
    end

    subgraph "Layer 3: Pre-processor"
        CSVConv["CSV/XML → JSON Converter"]:::core
        SELHooks["BMC SEL Decoder Hooks\ntools/SEL/"]:::optional
        CPERHooks["CPER Decoder Hooks\ntools/GB_CPER_Decoder/"]:::optional
    end

    subgraph "Layer 4: Analysis Engine"
        Engine["Analysis Engine\n(common/lib_log.py)"]:::core
    end

    subgraph "Layer 5: External Services"
        LLMService["Local LLM Service\n(e.g., Ollama/vLLM)"]:::external
        ADOService["Azure DevOps API"]:::external
    end

    subgraph "Layer 6: Reporting & Output"
        ReportGen["Report Generator"]:::core
        Outputs["Output Files\n(.log, .html, CSV, diffs)"]:::output
    end

    %% Connections
    CLI --> LLMConfig
    CLI --> SigConfig
    CLI --> Version
    CLI --> README
    CLI --> Req
    CLI --> CSVConv

    CSVConv --> SELHooks
    CSVConv --> CPERHooks
    CSVConv --> Engine

    Engine --> LLMService
    Engine --> ADOService
    Engine --> ReportGen

    ReportGen --> Outputs

    %% Click Events
    click CLI "https://github.com/microsoft/log_analyzer/blob/main/log_analyzer/log_analyzer.py"
    click LLMConfig "https://github.com/microsoft/log_analyzer/blob/main/common/llm_config.json"
    click SigConfig "https://github.com/microsoft/log_analyzer/blob/main/sut/settings.sample.json"
    click Engine "https://github.com/microsoft/log_analyzer/blob/main/common/lib_log.py"
    click Req "https://github.com/microsoft/log_analyzer/blob/main/requirements.txt"
    click Version "https://github.com/microsoft/log_analyzer/blob/main/log_analyzer/version.txt"
    click README "https://github.com/microsoft/log_analyzer/blob/main/README.md"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef config fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef output fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef optional fill:#FFF8DC,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
```
