Windows Event Logs

Learn how to forward Windows Event Logs to Sentry via the OpenTelemetry Protocol (OTLP).

This guide shows you how to collect Windows Event Logs and forward them to Sentry using the OpenTelemetry Collector with the Windows Event Log Receiver.

Before you begin, ensure you have:

  • A Windows Server or Windows machine (Windows Vista or later)
  • A Microsoft user account with permissions to access the Windows Event Log
  • A Microsoft user account with permissions to create Services (for running the collector as a service)
  • A Sentry project to send data to

The Windows Event Log Receiver is included in the OpenTelemetry Collector Contrib distribution. You'll need to download and install this version, as the standard otelcol binary does not include the Windows Event Log Receiver.

  1. Download the latest otelcol-contrib binary from the OpenTelemetry Collector releases page.

  2. Extract the binary to a directory, for example C:\otel-collector\.

  3. Create the service using the following command in an elevated Command Prompt or PowerShell:

Copied
sc.exe create otelcol-contrib displayname=otelcol-contrib start=delayed-auto binPath="C:\otel-collector\otelcol-contrib.exe --config C:\otel-collector\config.yaml"

Alternatively, you can install the OpenTelemetry Collector using the MSI installer:

  1. Download the latest MSI installer from the OpenTelemetry Collector releases page.

  2. Run the installer on your Windows Server.

  3. The service named otelcol-contrib will be created and started automatically upon completion.

You'll need your Sentry OTLP endpoint and authentication header. These can be found in your Sentry Project Settings under Client Keys (DSN) > OpenTelemetry (OTLP).

Copied
___OTLP_LOGS_URL___

Copied
x-sentry-auth: sentry sentry_key=___PUBLIC_KEY___

Create a configuration file at C:\otel-collector\config.yaml with the Windows Event Log Receiver and the OTLP HTTP exporter configured to send logs to Sentry.

This configuration collects logs from the three main Windows Event Log channels: Application, System, and Security.

config.yaml
Copied
receivers:
  windowseventlog/application:
    channel: application
  windowseventlog/system:
    channel: system
  windowseventlog/security:
    channel: security

processors:
  resourcedetection:
    detectors: [system]
    system:
      hostname_sources: ["os"]
  batch:
    send_batch_size: 1024
    send_batch_max_size: 2048
    timeout: "1s"

exporters:
  otlphttp/sentry:
    logs_endpoint: ___OTLP_LOGS_URL___
    headers:
      x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
    compression: gzip
    encoding: proto

service:
  pipelines:
    logs:
      receivers:
        - windowseventlog/application
        - windowseventlog/system
        - windowseventlog/security
      processors:
        - resourcedetection
        - batch
      exporters:
        - otlphttp/sentry

The Windows Event Log Receiver supports several configuration options:

OptionDefaultDescription
channelrequiredThe Windows Event Log channel to monitor (e.g., application, system, security)
start_atendWhere to start reading logs on first startup (beginning or end)
poll_interval1sInterval at which the channel is checked for new log entries
max_reads100Maximum number of records read into memory before starting a new batch
rawfalseIf true, the log body contains the original XML string instead of a structured representation
exclude_providers[]List of event log providers to exclude from processing

You can use XML queries to filter specific events. This example only forwards logs from specific providers:

config.yaml
Copied
receivers:
  windowseventlog/filtered:
    query: |
      <QueryList>
        <Query Id="0">
          <Select Path="Application">*[System[Provider[@Name='MyApp']]]</Select>
          <Select Path="System">*[System[Level&lt;=2]]</Select>
        </Query>
      </QueryList>

The query above collects:

  • All events from the MyApp provider in the Application channel
  • Events with severity level 2 (Error) or lower from the System channel

For more information on XML query syntax, see Microsoft's Query Schema documentation.

You can collect Windows Event Logs from remote machines by configuring the remote option:

config.yaml
Copied
receivers:
  windowseventlog/remote:
    channel: application
    remote:
      server: "remote-server"
      username: "user"
      password: "password"
      domain: "domain"

Once you've created your configuration file, configure the restart settings and start the service:

Copied
sc.exe failure otelcol-contrib reset= 86400 actions= restart/5000/restart/5000/restart/5000
sc.exe start otelcol-contrib

If logs aren't appearing in Sentry, you can add a debug exporter to troubleshoot:

  1. Stop the service:
Copied
sc.exe stop otelcol-contrib
  1. Create a debug configuration file (config_debug.yaml) with a debug exporter:
config_debug.yaml
Copied
receivers:
  windowseventlog/application:
    channel: application

processors:
  batch:

exporters:
  debug:
    verbosity: detailed
  otlphttp/sentry:
    logs_endpoint: ___OTLP_LOGS_URL___
    headers:
      x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
    compression: gzip
    encoding: proto

service:
  pipelines:
    logs:
      receivers:
        - windowseventlog/application
      processors:
        - batch
      exporters:
        - otlphttp/sentry
        - debug
  1. Run the collector manually to see debug output:
Copied
C:\otel-collector\otelcol-contrib.exe --config C:\otel-collector\config_debug.yaml
  1. Review the console output to verify events are being processed correctly.

  2. If events are processed but not reaching Sentry, check:

    • Network connectivity to Sentry's ingestion endpoint
    • Firewall rules allowing outbound HTTPS traffic
    • The correctness of your Sentry credentials

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").