👌 IMPROVE: Update Prometheus and Grafana images, enhance Hetzner DNS mapping, and add Prometheus reload functionality
This commit is contained in:
@@ -7,8 +7,10 @@ from dotenv import load_dotenv
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
# 🔑 Load Hetzner API Token
|
||||
# 🔑 Load Hetzner API Token & Prometheus URL
|
||||
HETZNER_API_TOKEN = os.getenv("HETZNER_API_TOKEN")
|
||||
# https://prometheus.io/docs/prometheus/latest/configuration/configuration/
|
||||
PROMETHEUS_RELOAD_URL = os.getenv("PROMETHEUS_RELOAD_URL", "https://prometheus.phx-erp.de:9090/-/reload")
|
||||
|
||||
# Check if token is loaded
|
||||
if not HETZNER_API_TOKEN:
|
||||
@@ -143,6 +145,16 @@ def generate_prometheus_sd_config():
|
||||
else:
|
||||
print("✅ No servers were excluded due to the darklist.")
|
||||
|
||||
# 🔄 **Trigger Prometheus Reload**
|
||||
try:
|
||||
response = requests.post(PROMETHEUS_RELOAD_URL)
|
||||
if response.status_code == 200:
|
||||
print("🔄 ✅ Prometheus configuration reloaded successfully!")
|
||||
else:
|
||||
print(f"⚠️ Warning: Prometheus reload failed with status {response.status_code}: {response.text}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"❌ Error reloading Prometheus: {e}")
|
||||
|
||||
# 🔄 Run the script
|
||||
if __name__ == "__main__":
|
||||
generate_prometheus_sd_config()
|
||||
Reference in New Issue
Block a user