# OpenTelemetry Collector — ready-to-use Windows Server config
# Pairs with: https://linkmesh.io/blog/monitor-windows-server-opentelemetry-grafana/
#
# 1. Save as:  C:\Program Files\OpenTelemetry Collector\config.yaml
# 2. Replace the two <...> values below with your Grafana Cloud OTLP details
#    (Grafana Cloud → Connections → OTLP → "Send data").
# 3. Restart the service in services.msc: "OpenTelemetry Collector".
#
# Self-hosting instead of Grafana Cloud? Swap the exporter — see the guide.

receivers:
  # Task Manager-style system metrics: CPU, memory, disks, network.
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu:
      memory:
      network:
      paging:
      processes:
      filesystem:        # disk free space (% and bytes)

  # Values from Performance Monitor (perfmon).
  windowsperfcounters:
    collection_interval: 30s
    perfcounters:
      - object: Processor
        instances: ["_Total"]
        counters: [{ name: "% Processor Time" }]
      - object: Memory
        counters: [{ name: "Available Bytes" }]
      - object: LogicalDisk
        instances: ["*"]
        counters: [{ name: "% Free Space" }]
      - object: System
        counters: [{ name: "System Up Time" }]

  # Entries from Event Viewer.
  windowseventlog/system:
    channel: System
  windowseventlog/application:
    channel: Application
  windowseventlog/security:
    channel: Security

processors:
  # Stamps every stream with the Windows hostname, OS, etc.
  resourcedetection:
    detectors: [system]
  batch:

exporters:
  # Where Windows sends the data. Grafana Cloud's single OTLP endpoint
  # takes both metrics and logs.
  otlphttp/grafana:
    endpoint: "https://otlp-gateway-<zone>.grafana.net/otlp"
    headers:
      Authorization: "Basic <base64 of instanceID:token>"

service:
  pipelines:
    metrics:
      receivers: [hostmetrics, windowsperfcounters]
      processors: [resourcedetection, batch]
      exporters: [otlphttp/grafana]
    logs:
      receivers:
        [windowseventlog/system, windowseventlog/application, windowseventlog/security]
      processors: [resourcedetection, batch]
      exporters: [otlphttp/grafana]
