How to Configure Windows Sandbox Local Grafana Loki Log Engine via XML in Windows 11

Log aggregation pipelines are critical for monitoring distributed microservices, inspecting error traces, and verifying log shipping agents such as Promtail or Fluent Bit. However, running local log aggregation backends directly on a developer workstation can clutter system directories and consume persistent storage. In Windows 11, Windows Sandbox provides a lightweight, fully disposable virtual environment. By authoring custom Windows Sandbox XML (.wsb) configuration files, you can deploy a standalone Grafana Loki log engine in seconds.

Architecture of the Disposable Loki Sandbox

Windows Sandbox provides an isolated Hyper-V guest operating system that resets completely upon closure. To provision an automated Loki testing environment, our architecture consists of two files residing on the host workstation:

  • A mapped host folder: A directory containing the standalone loki-windows-amd64.exe executable and a minimal configuration YAML file.
  • A sandbox configuration file: An XML blueprint file (.wsb) specifying shared folder mounting and an automated LogonCommand.

Authoring the Windows Sandbox WSB Blueprint

Create a dedicated host folder, such as C:\SandboxLoki. Download the Windows binary of Grafana Loki into this directory. Then create LaunchLoki.wsb with the following XML structure:

<Configuration>
  <VGpu>Default</VGpu>
  <Networking>Default</Networking>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\SandboxLoki</HostFolder>
      <SandboxFolder>C:\LokiFiles</SandboxFolder>
      <ReadOnly>false</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\LokiFiles\Start-Loki.ps1</Command>
  </LogonCommand>
</Configuration>

Authoring Loki Configuration and Startup Script

Inside the mapped host folder (C:\SandboxLoki), create a minimal configuration file named loki-config.yaml:

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

common:
  path_prefix: C:\LokiFiles\loki_data
  storage:
    filesystem:
      chunks_directory: C:\LokiFiles\loki_data\chunks
      rules_directory: C:\LokiFiles\loki_data\rules
  replication_factor: 1
  ring:
    kvstore:
      store: inmemory

schema_config:
  configs:
    - from: 2020-10-24
      store: tsdb
      object_store: filesystem
      schema: v13
      index:
        prefix: index_
        period: 24h

Next, create the automated PowerShell initialization script named Start-Loki.ps1:

Write-Host "=============================================" -ForegroundColor Cyan
Write-Host " Starting Grafana Loki Log Engine in Sandbox  " -ForegroundColor Green
Write-Host " HTTP Endpoint: http://127.0.0.1:3100        " -ForegroundColor Yellow
Write-Host " Ready Check:   http://127.0.0.1:3100/ready  " -ForegroundColor Yellow
Write-Host "=============================================" -ForegroundColor Cyan

# Create data directories if missing
New-Item -Path "C:\LokiFiles\loki_data" -ItemType Directory -Force | Out-Null

# Launch Loki server
& "C:\LokiFiles\loki-windows-amd64.exe" -config.file "C:\LokiFiles\loki-config.yaml"

Running and Validating Loki in the Sandbox

Double-click LaunchLoki.wsb on your Windows 11 host. Windows Sandbox boots up, mounts the mapped folder, and immediately launches Grafana Loki inside an interactive PowerShell window.

Loki starts listening on port 3100. Open Microsoft Edge inside the sandbox and navigate to http://127.0.0.1:3100/ready to confirm ready status.

You can push log entries using curl or connect local log shippers to test LogQL queries in total isolation. Once testing is complete, closing the sandbox window instantly eliminates all log chunks, index tables, and server processes, leaving your host system clean and unburdened.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.