[monitor-server, monitor-config] fix: preserve Prometheus targets across server restarts - #153
Conversation
da09635 to
55a3659
Compare
55a3659 to
01671fa
Compare
|
Since the collected data is already persisted across restarts, is my understanding correct that this PR specifically addresses the loss of Prometheus scrape targets when RL-Insight is stopped and restarted while a training job is still running? |
Yes, that is correct. Actually The collected data have been already stored in the TSDB, so Grafana can display them normally; they are not affected by this issue. This PR persists the dynamically registered scrape targets, so when RL-Insight and Prometheus are restarted while a training job is still running, Prometheus can rediscover those targets and continue collecting new metrics without requiring the training job to register again. |
|
[review] Could you please provide examples of both the generated prometheus-targets.yml and the corresponding runtime prometheus.yml? I’d like to understand what the final file structures look like after this change. |
|
[review] Could you clarify the main benefit of introducing file_sd_configs here? Since all monitoring targets are still stored together in a YAML file, would it be simpler to continue writing them directly to prometheus.yml and preserve that file across restarts? The current approach seems to introduce additional label conversion and migration complexity. |
Here are examples of the final generated files. - targets:
- 178.110.22.2:9092
labels:
rl_insight_job: trainer_metrics
- targets:
- 178.110.22.2:38079
labels:
rl_insight_job: transfer_queue
- targets:
- 178.110.22.2:34245
labels:
replica: "1"
rl_insight_job: vllm
- targets:
- 178.110.22.2:43475
labels:
replica: "0"
rl_insight_job: vllmThe corresponding runtime prometheus.yml: global:
scrape_interval: 10s
scrape_configs:
- job_name: rl-insight-dynamic
file_sd_configs:
- files:
- /root/.rl-insight/data/targets/prometheus-targets.yml
refresh_interval: 5s
relabel_configs:
- source_labels:
- rl_insight_job
target_label: job
- regex: rl_insight_job
action: labeldropPrometheus reads all entries from the targets file every five seconds. The rl_insight_job label is copied to the standard job label and then removed, while labels such as replica are preserved. On restart, RL-Insight regenerates prometheus.yml with the same file_sd_configs reference without overwriting the persisted targets file. |
The main motivation is to separate relatively static Prometheus service configuration from dynamic target-discovery state.
This creates a clear responsibility boundary: Prometheus service configuration remains stable and reproducible, while dynamic targets can be updated independently and concurrently. Each registration only modifies a small discovery file instead of coupling every target change to a rewrite of the complete Prometheus configuration. |
I agree that file_sd_configs is valuable for supporting multiple experiments. At the moment, however, targets from all experiments are still stored in a single discovery file, which is not significantly different from keeping them together in prometheus.yml from an experiment-isolation perspective. |
|
Thanks, and your understanding is correct: the current implementation stores all targets in a single discovery file, so it does not yet provide per-experiment isolation. To make sure we’re aligned on the scope of this PR, are you suggesting that this bugfix should only prevent the existing |
|
@mayunaise I prefer the second option: keep file_sd_configs in this PR, and defer per-experiment target-file partitioning to a follow-up TODO. |
|
@mengchengTang That makes sense. I’ll add a corresponding TODO and leave per-experiment target-file partitioning as a follow-up feature. |
01671fa to
6554200
Compare
|
approve |
What does this PR do?
Fixes #145.
rl-insight server startpreviously regenerated the runtimeprometheus.ymlfrom an empty template and discarded dynamically registered scrape targets. Prometheus then stopped scraping running trainers until they registered again.This change separates generated Prometheus configuration from dynamic target state:
~/.rl-insight/data/targets/prometheus-targets.ymlfile_sd_configsfcntlonly in the Linux server-side file-lock path, so Windows training clients can still import and use the public APIsNo public API behavior changes are introduced. The
prometheus_reloadedresponse field and both manual and automatic reload capabilities remain unchanged.Closes #145.
Checklist Before Starting
Test
The fix was also validated against a live verl training job: after restarting the RL-Insight stack, Prometheus rediscovered the persisted trainer, TransferQueue, and vLLM targets without restarting training.
API and Usage Example
No public trainer API changes are required. Existing registration continues to work:
Registered targets are stored in:
Design & Code Changes
file_sd_configsprometheus.ymlstatic_configsChecklist Before Submitting