How amritanshu-pandey/otel-sungrow-receiver works
Main Components
• Go Application (main.go): Represents the core service that performs the Modbus communication, metrics collection, scaling/rounding logic, and exposes metrics via an HTTP endpoint.
• Configuration Module (config.yaml): Provides the settings, such as Modbus parameters and metric definitions, which the application reads on startup.
• Modbus Communication: The component responsible for connecting to the Sungrow inverter (via Modbus TCP) and reading registers.
• Metrics Export Endpoint: The built-in HTTP server that serves the metrics in Prometheus format (default port 9100).
• Prometheus: An external system configured to scrape the HTTP endpoint, as indicated by the example configuration in the README.
• Containerization Setup: The Dockerfile and docker-compose.yaml illustrate how the application is packaged and deployed.
• Grafana Dashboards: The JSON file in the grafana-dashboards directory shows a predefined dashboard for visualizing the metrics.
Out the Relationships and Data Flow
• The Go Application initializes by loading configuration parameters from config.yaml.
• It then establishes a Modbus TCP connection to the Sungrow inverter to poll registers on a predefined interval.
• Collected metrics (after potential scaling and formatting) are served via an HTTP server in a format understandable by Prometheus.
• Prometheus periodically scrapes these metrics from the exporter’s HTTP endpoint.
• Grafana uses the scraped/promoted metrics data from Prometheus to display visual dashboards for monitoring.
• The containerization piece (Dockerfile/docker-compose.yaml) encapsulates the entire setup, allowing for easy deployment in containerized environments.
Important Architectural Patterns
• Separation of Concerns: The configuration, communication, and metrics-serving functionalities are clearly separated.
• Polling/Streaming Data Collection: The system follows a periodic polling pattern to read data from the inverter.
• Open Telemetry Receiver Support (future intention) ensures modularity so the system can be extended to support other telemetry backends besides Prometheus.
• Containerization ensures portability and environment consistency.