feat(slurm): Add native Prometheus OpenMetrics telemetry for Slurm >= 25.11#5824
feat(slurm): Add native Prometheus OpenMetrics telemetry for Slurm >= 25.11#5824AdarshK15 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Slurm configuration generation logic into an object-oriented structure to support multiple Slurm versions, introducing specific generators for Slurm 24.11, 25.05, and 25.11. It also adds support for native Prometheus OpenMetrics telemetry via Slurm and Google Cloud Ops Agent, and introduces an experimental enable_async_reply setting. The review feedback highlights a potential KeyError in setup.py when initializing nested dictionaries for the Ops Agent configuration, suggesting a safer initialization approach.
fedff16 to
f252554
Compare
f252554 to
628ceea
Compare
|
/gemini summary |
|
/gemini review |
Summary of ChangesThis pull request enables native Prometheus OpenMetrics telemetry for Slurm controllers on GCP. By leveraging Slurm's built-in metrics plugin and configuring the Google Cloud Ops Agent to scrape targeted endpoints, the changes provide improved cluster-level observability. The implementation includes version-aware logic to ensure compatibility and safe configuration injection, with comprehensive testing to validate the feature across different Slurm versions. Highlights
Activity
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for native Prometheus OpenMetrics telemetry via Slurm and the Google Cloud Ops Agent by adding the enable_openmetrics configuration option. Feedback on the changes highlights two key areas of improvement in the Ops Agent setup script: first, ensuring that the prometheus_pipeline is initialized with the required exporters list (e.g., ["google"]) to prevent configuration validation failures; and second, implementing a cleanup mechanism to remove the slurm_prometheus receiver and pipeline references if enable_openmetrics is subsequently disabled.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for native Prometheus OpenMetrics telemetry via Slurm and the Google Cloud Ops Agent by introducing the enable_openmetrics configuration option. Feedback on the changes highlights two main areas for improvement: first, the cleanup logic in setup.py should recursively remove empty parent configurations (such as prometheus_pipeline and metrics) when slurm_prometheus is removed, preventing Google Cloud Ops Agent validation failures; second, retrieving slurm_control_host_port from lkp.cfg should use a defensive .get() call with a default value to avoid potential AttributeErrors.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the enable_openmetrics variable to enable native Prometheus OpenMetrics telemetry via Slurm and the Google Cloud Ops Agent on Slurm version 25.11 and above. Feedback on the changes suggests using getattr instead of .get() on the configuration object to prevent AttributeError during unit tests, and raising an explicit ValueError if the user enables OpenMetrics on an unsupported Slurm version rather than silently skipping the configuration.
Summary
This PR introduces
native OpenMetrics (Prometheus)telemetry support to the Slurm controller module (schedmd-slurm-gcp-v6-controller), exporting Slurm metrics directly to Google Cloud Monitoring.For Slurm clusters running version >= 25.11, this implementation leverages Slurm's native metrics/openmetrics plugin for Prometheus exporter. These metrics are exported directly from the
slurmctlddaemon natively, they are collected and exported from the controller instance only.List of supported endpoints:
To know more about these endpoints, visit the SchedMD Metrics Documentation.
Targeted Scraping
Because the root
/metricsendpoint returns a plain-text index instead of raw OpenMetrics payloads, the Google Cloud Ops Agent cannot scrape it directly. To handle this, we explicitly configure distinct scrape jobs to target the sub-endpoints individually.Additionally, we intentionally omit scraping the
/metrics/jobs-users-acctsendpoint. This endpoint duplicates job metrics broken down by every user and account, which introduces excessively high metric cardinality and bloat without adding significant value to cluster-level observability.Key Changes
enable_openmetricsboolean variable to the controller andslurm_filesmodules.conf_v2511.pyto conditionally injectMetricsType=metrics/openmetricsinto theslurm.confgeneration logic.setup.pyto dynamically inject the Prometheus receiver into/etc/google-cloud-ops-agent/config.yaml, configuring the 4 targeted scrape jobs.Testing & Cluster Validation
Tested manually with a live cluster running Slurm 25.11.
1. Configuration Check:
Verified that the OpenMetrics plugin was correctly injected into the Slurm configuration:
2. OpenMetrics Endpoint: Verified that the controller natively exposes Prometheus parseable metrics on the control host port (6818) by querying one of the targeted sub-paths.
3. Ops Agent Pipeline: Verified that the Python setup scripts successfully injected the safe receiver and pipeline definitions into the Ops Agent without overwriting existing logging pipelines.
4. Cloud Monitoring: Verified that metrics are exposed in GCP Metric Explorer under
Prometheus/Slurm.Backward Compatibility
Verified backward compatibility by setting
enable_openmetrics = truein the blueprint for a cluster with Slurm version 25.05. The version checking logic successfully caught the unsupported version, ensuring that the Ops Agent safely skipped configuring the Prometheus receivers and pipelines, and thatMetricsType=metrics/openmetricswas not injected into the Slurm config.Usage Example
To enable this feature, set enable_openmetrics to true on the controller module in your blueprint. Note that this requires a Slurm version of 25.11 or higher.