@@ -84,9 +84,9 @@ def add_target():
8484 }
8585 config ['scrape_configs' ].append (new_job )
8686
87- update_prometheus_container ()
8887 save_yaml (config , prometheus_yml_path )
8988 flash ('Target added successfully!' , 'success' )
89+ update_prometheus_container ()
9090 return redirect (url_for ('targets' ))
9191
9292@app .route ('/targets/remove_target' , methods = ['POST' ])
@@ -102,7 +102,6 @@ def remove_target():
102102 targets .remove (target_to_remove )
103103 flash (f'Target { target_to_remove } removed successfully!' , 'success' )
104104
105- update_prometheus_container ()
106105 # Check if this was the last target, then remove the job
107106 if not targets : # If the list is now empty
108107 config ['scrape_configs' ].remove (scrape_config )
@@ -114,6 +113,7 @@ def remove_target():
114113 flash (f'Job { job_name } not found.' , 'warning' )
115114
116115 save_yaml (config , prometheus_yml_path )
116+ update_prometheus_container ()
117117 return redirect (url_for ('targets' ))
118118
119119@app .route ('/targets/change_interval' , methods = ['POST' ])
@@ -126,8 +126,8 @@ def change_interval():
126126 if scrape_config ['job_name' ] == job_name :
127127 scrape_config ['scrape_interval' ] = new_interval
128128 flash ('Scrape interval updated successfully!' , 'success' )
129- update_prometheus_container ()
130129 break
131130
132131 save_yaml (config , prometheus_yml_path )
132+ update_prometheus_container ()
133133 return redirect (url_for ('targets' ))
0 commit comments