File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ def add_target():
101101
102102 job_found = False
103103
104+ # if job name already exists, add new target to the job
104105 for scrape_config in config ['scrape_configs' ]:
105106 if scrape_config ['job_name' ] == job_name :
106107 # Append new target
@@ -115,13 +116,7 @@ def add_target():
115116 updated_job ['job_name' ] = scrape_config ['job_name' ]
116117 updated_job ['static_configs' ] = scrape_config ['static_configs' ]
117118 updated_job ['scrape_interval' ] = scrape_config ['scrape_interval' ]
118-
119- # Update basic_auth if provided
120- if username and password :
121- updated_job ['basic_auth' ] = {
122- 'username' : username ,
123- 'password' : password
124- }
119+ updated_job ['basic_auth' ] = scrape_config .get ('basic_auth' , None )
125120
126121 # Replace the existing job with the updated one
127122 index = config ['scrape_configs' ].index (scrape_config )
Original file line number Diff line number Diff line change @@ -68,13 +68,11 @@ <h2>Restart Prometheus Docker Service</h2>
6868 < div class ="section ">
6969 < h2 > Add New Target</ h2 >
7070 < form action ="{{ url_for('add_target') }} " method ="post " class ="add-target-form ">
71- < input type ="text " name ="job_name " placeholder ="Group Name " required class ="input-field ">
72- < input type ="text " name ="new_target " placeholder ="New Target " required class ="input-field ">
73- < input type ="text " name ="scrape_interval " placeholder ="Scrape Interval " required class ="input-field ">
74- < input type ="text " name ="username " placeholder ="Username " required class ="input-field ">
75- <!-- New Username field -->
76- < input type ="password " name ="password " placeholder ="Password " required class ="input-field ">
77- <!-- New Password field -->
71+ < input type ="text " name ="job_name " value ="localhost " class ="input-field " required >
72+ < input type ="text " name ="new_target " placeholder ="New Target " class ="input-field " required >
73+ < input type ="text " name ="scrape_interval " placeholder ="Scrape Interval " class ="input-field " required >
74+ < input type ="text " name ="username " placeholder ="Username " class ="input-field ">
75+ < input type ="password " name ="password " placeholder ="Password " class ="input-field ">
7876 < br >
7977 < button type ="submit " class ="btn btn-primary btn-lg ">
8078 < i class ="fas fa-plus "> </ i > Add Target
You can’t perform that action at this time.
0 commit comments