HardwareExporterWeb

March 8, 2026 · View on GitHub

English | 简体中文 | 日本語

HardwareExporterWeb is an optional companion service for HardwareExporterWindows that provides automatic service discovery for Prometheus.

What It Does

HardwareExporterWeb is not a metrics collector - it's a service discovery tool that:

  • 🔍 Automatically scans your local network to discover Windows machines
  • 📡 Provides Prometheus HTTP Service Discovery endpoints
  • 🌐 Offers a web interface to manage discovered hosts
  • 🌍 Supports multiple languages (English, Chinese, Japanese)

Why Use It?

Instead of manually configuring each monitoring target in prometheus.yml:

# Manual configuration (tedious)
scrape_configs:
  - job_name: 'windows-hardware'
    static_configs:
      - targets:
          - '192.168.1.100:9888'
          - '192.168.1.101:9888'
          - '192.168.1.102:9888'
          # ... add more manually

Use automatic service discovery:

# Automatic discovery (dynamic)
scrape_configs:
  - job_name: 'windows-hardware-auto'
    http_sd_configs:
      - url: 'http://your-web-server/api/ServiceDiscovery/HardwareExporter'
        refresh_interval: 60s

Installation

Prerequisites

  • .NET 10.0 Runtime
  • Network access to scan subnet

Quick Start

  1. Download HardwareExporterWeb-win-x64.zip from the latest release
  2. Extract to your desired location
  3. Edit appsettings.json (optional)
  4. Run HardwareExporterWeb.exe

The web interface will be available at http://localhost:80 by default.

Configuration

Edit appsettings.json:

{
  "NetworkScan": {
    "SubnetFilter": "",           // Empty = scan all local subnets
    "SubnetMask": "255.255.255.0" // Subnet mask for scanning
  },
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://0.0.0.0:80"
      }
    }
  }
}

Network Scan Options

OptionTypeDefaultDescription
SubnetFilterstring""Optional subnet filter (e.g., "10.100.100"). Empty = scan all local subnets
SubnetMaskstring"255.255.255.0"Subnet mask for network scanning

Examples

Scan all local subnets:

"SubnetFilter": ""

Scan specific subnet only:

"SubnetFilter": "10.100.100"

Use different subnet mask:

"SubnetMask": "255.255.0.0"

API Endpoints

Service Discovery

  • GET /api/ServiceDiscovery/HardwareExporter

    • Returns list of discovered HardwareExporter instances
    • Format: Prometheus HTTP SD compatible JSON
  • GET /api/ServiceDiscovery/WindowsExporter

    • Returns list of discovered windows_exporter instances
    • Format: Prometheus HTTP SD compatible JSON

Response Format

[
  {
    "targets": ["192.168.1.100:9888"],
    "labels": {
      "ip": "192.168.1.100",
      "hostname": "DESKTOP-ABC123"
    }
  }
]

Prometheus Configuration

HTTP Service Discovery

scrape_configs:
  - job_name: 'hardware-exporter-auto'
    http_sd_configs:
      - url: 'http://your-web-server/api/ServiceDiscovery/HardwareExporter'
        refresh_interval: 60s
    
  - job_name: 'windows-exporter-auto'
    http_sd_configs:
      - url: 'http://your-web-server/api/ServiceDiscovery/WindowsExporter'
        refresh_interval: 60s

Web Interface

The web interface provides:

  • 📊 View discovered hosts
  • ➕ Manually add hosts
  • ✏️ Edit host information
  • 🗑️ Remove hosts
  • 🌐 Multi-language support (EN/CN/JP)

Access the web interface at http://localhost:80 (or your configured port).

Language Support

The web interface supports three languages:

  • 🇺🇸 English
  • 🇨🇳 简体中文 (Simplified Chinese)
  • 🇯🇵 日本語 (Japanese)

Use the language selector in the top-right corner to switch languages.

Architecture

┌─────────────────────────────────────┐
│   Prometheus Server                 │
│   (pulls from HTTP SD endpoints)    │
└──────────────┬──────────────────────┘

               │ HTTP SD API

┌──────────────▼──────────────────────┐
│   HardwareExporterWeb               │
│   - Network Scanner                 │
│   - Host Manager                    │
│   - Web UI                          │
└──────────────┬──────────────────────┘

               │ ARP Scan

┌──────────────▼──────────────────────┐
│   Local Network                     │
│   - Windows machines with           │
│     HardwareExporter                │
│   - Windows machines with           │
│     windows_exporter                │
└─────────────────────────────────────┘

Development

Building from Source

cd src/HardwareExporterWeb
dotnet build

Running in Development

cd src/HardwareExporterWeb
dotnet run

Running Tests

cd test/HardwareExporterWeb.Tests
dotnet test

Troubleshooting

Service not discovering hosts

  1. Check network connectivity
  2. Verify subnet configuration in appsettings.json
  3. Ensure target machines are running HardwareExporter or windows_exporter
  4. Check firewall rules allow network scanning

Web interface not accessible

  1. Check if port 80 is already in use
  2. Try changing the port in appsettings.json
  3. Verify firewall allows incoming connections
  4. Check application logs for errors

Prometheus not picking up targets

  1. Verify the HTTP SD URL is correct
  2. Check Prometheus logs for SD errors
  3. Test the API endpoint manually: curl http://your-server/api/ServiceDiscovery/HardwareExporter
  4. Ensure refresh_interval is set appropriately

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.