diff --git a/automation/generate-scrape-config.py b/automation/generate-scrape-config.py index 9e4df7d..9935e6e 100644 --- a/automation/generate-scrape-config.py +++ b/automation/generate-scrape-config.py @@ -9,7 +9,7 @@ REPOS = { } TMP_DIR = ".tmp-repos" -OUTPUT_FILE = ".tmp-repos/observability-stack/manifests/prometheus-scrape-secret/additional-scrape-configs.yaml" +OUTPUT_FILE = os.path.join(TMP_DIR, "observability-stack/manifests/prometheus-scrape-secret/additional-scrape-configs.yaml") os.makedirs(TMP_DIR, exist_ok=True) @@ -37,11 +37,11 @@ def write_scrape_config(jobs): for repo, targets in jobs.items(): result.append({ "job_name": repo, - "static_configs": [ - {"targets": targets} - ] + "static_configs": [{"targets": targets}] }) + scrape_yaml = "# This content will be auto-updated by the pipeline\n" + yaml.dump(result, sort_keys=False) + secret = { "apiVersion": "v1", "kind": "Secret", @@ -54,13 +54,13 @@ def write_scrape_config(jobs): }, "type": "Opaque", "stringData": { - "additional-scrape-configs.yaml": "# This content will be auto-updated by the pipeline\n" + yaml.dump(result) + "additional-scrape-configs.yaml": scrape_yaml } } os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True) with open(OUTPUT_FILE, "w") as f: - yaml.dump(secret, f) + yaml.dump(secret, f, sort_keys=False) if __name__ == "__main__": jobs = collect_targets() diff --git a/automation/scrape-sync.sh b/automation/scrape-sync.sh index f375bc7..072d7b5 100644 --- a/automation/scrape-sync.sh +++ b/automation/scrape-sync.sh @@ -23,6 +23,4 @@ else git add manifests/prometheus-scrape-secret/additional-scrape-configs.yaml git commit -m "auto: update Prometheus scrape config" git push origin master -fi - -cat .tmp-repos/observability-stack/manifests/prometheus-scrape-secret/additional-scrape-configs.yaml +fi \ No newline at end of file