Skip to content

Commit 7b078bf

Browse files
chore: bug fixed with updating container
1 parent c80881d commit 7b078bf

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

src/routes/prometheus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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'))

src/scripts/prometheus.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,11 @@ mkdir -p "$PROMETHEUS_DATA_DIR"
4242
# Create the prometheus.yml configuration file
4343
log "Generating prometheus.yml configuration file."
4444
cat > "$PROMETHEUS_CONFIG_FILE" <<EOL
45-
global:
46-
scrape_interval: $SCRAPING_INTERVAL
47-
# how frequently to scrape targets from the target list
48-
4945
scrape_configs:
5046
- job_name: $JOB_NAME
5147
static_configs:
52-
- targets: ['$FLASK_APP_IP:$FLASK_APP_PORT']
53-
54-
# apeend more targets list to scrape metrics from multiple services, on central prometheus server
55-
# first ip address in the local machine ip address list
48+
- targets:
49+
- '$FLASK_APP_IP:$FLASK_APP_PORT'
5650
EOL
5751

5852
# Check if Docker network exists

0 commit comments

Comments
 (0)