How sladkoff/minecraft-prometheus-exporter works
Main Components
• Plugin Core and Initialization: Represent the starting point of the plugin (e.g., MetricsServer.java, PrometheusExporter.kt). This is where the plugin is loaded into the Minecraft server.
• HTTP Endpoint Module: Separate components that expose the two primary endpoints:
• /metrics endpoint (using MetricsController.java)
• /health endpoint (using HealthController.java)
• Configuration Management: Show the configuration flow that the plugin follows (environment variables, system properties, then configuration file). This includes classes such as MetricConfig.java, PluginConfig.java, and PrometheusExporterConfig.java.
• Metrics Collection & Aggregation:
• Collectors (e.g., LoadedChunksCollector.java, TpsCollector.java, TickDurationCollector.java) and metric aggregation classes (e.g., MetricRegistry.java, various classes in the metrics package).
• Player-specific metrics collectors (in src/main/java/de/sldk/mc/metrics/player).
• Health Checks: Indicate the health check framework (HealthCheck.java and its implementations, e.g., ConcurrentHealthChecks.java, HealthChecks.java) that aggregates custom health checks.
• External Integration:
• Integration with Prometheus (via the Prometheus client libraries) and describe how Grafana dashboards (the JSON files in the dashboards directory) consume exposed metrics.
• Docker support (docker-compose.yml) for containerized deployments if relevant in deployment mode.
Relationships and Interactions
• How the Plugin Core initializes and wires together its configuration, metrics collection, and HTTP endpoint setup.
• Configuration flow – from environment variables (highest priority) through system properties, and finally to the plugin’s own configuration file.
Important Architectural Patterns and Principles
• Separation of Concerns: Distinguish between data collection (metrics, health checks), configuration management, and the HTTP API endpoints.
• Dependency Injection: Note that configuration and custom health checks are aggregated via service management (see how HealthChecks is loaded and enriched).
• Extensibility: Point out the capability for third-party integrations (both for custom metrics and health checks) as described in the README. For example, use of external libraries (prometheus simpleclient for metric registration) and integration of custom plugin health checks.
• Modularity: Emphasize the different packages corresponding to "collectors," "metrics," "config," "health," and "utils." Each package encapsulates a focused part of the functionality.
Additional Details for the Engineer
• Listing Java/Kotlin as the main technologies and Maven as the build tool (pom.xml is used for dependency management).
• External integrations like Prometheus's scraping and Grafana dashboards (dashboard JSON files are provided).
• Testing and continuous integration aspects (GitHub workflows related to testing and releasing) to show how deployment integrity is maintained.
• That while it is modular, most of the operational logic revolves around two primary endpoints (/metrics & /health) which act as the main interface for monitoring.