How sapcc/redfish-exporter works
Project Type and Purpose
• This is a backend microservice (a Prometheus exporter) written in Python.
• Its purpose is to expose HTTP endpoints (/health, /firmware, /performance) that collect metrics from servers via the Redfish API and present them in Prometheus format.
File Structure
• Top-level files:
• main.py – entry point, starts the HTTP server (Prometheus client exposition or built-in HTTP handler)
• handler.py – routes incoming HTTP calls to the appropriate collector
• collector.py – defines the base collector interface and metric registration logic
• config.yml + requirements.txt + Dockerfile + .github/workflows – configuration, dependencies, CI/CD, and containerization
• collectors/ package – four specialized collectors:
– health_collector.py
– firmware_collector.py
– performance_collector.py
– certificate_collector.py
• Infrastructure scripts: redfish-exporter.sh, dockerbuild.ps1
• CI: CodeQL and Pylint workflows
Extract README Insights
• Key technologies: Python 3.6+, Prometheus Python client library, Redfish API
• Configuration via config.yml or environment variables
• Runs standalone or in Docker, listens on port 9220 by default
Main Components and Interactions
a. Components
1. HTTP Server (Prometheus exposition endpoint)
2. Request Router/Handler (handler.py)
3. Collector Manager (collector.py)
4. Individual Collector Modules (collectors/…)
5. Redfish API Client (internal HTTP calls to target servers)
6. Config & Credentials Provider (reads config.yml + env vars)
7. Prometheus Metrics Registry (in-memory gauge metrics)
8. External Targets (servers with Redfish API)
9. Container & CI/CD (Docker, GitHub Actions)
b. Interactions / Data Flow
1. User or Prometheus server sends HTTP GET to /health, /firmware, or /performance on exporter.
2. HTTP Server forwards request to handler.py.
3. Handler parses query params (target, job, etc.), fetches config/credentials.
4. Handler invokes the appropriate Collector via the Collector Manager.
5. Collector module performs HTTP calls to the target server’s Redfish API.
6. Collector parses JSON, pushes gauge metrics into the Prometheus Registry.
7. Handler returns success/failure status; metrics become available at the /metrics endpoint.
c. Architectural Patterns and Principles
• Plugin-style collectors: each metric category is isolated in its own module
• Single-process, event-driven HTTP server
• Configuration as code + environment variable overrides
• Docker-friendly: container build and run scripts included
d. Key Technologies & Frameworks
• Python 3.6+ with prometheus_client library
• Redfish API over HTTPS
• Docker for containerization
• GitHub Actions for CI (CodeQL security scanning, Pylint linting)
Detailed Elements to Capture
• Intra-process breakdown:
• Main entry (main.py)
• Routing logic (handler.py)
• Collector base (collector.py) vs. specialized collectors
• Configuration flow: config.yml + environment variables
• Prometheus client registry & exposition endpoint
• External HTTP calls to Redfish API