Mercurial > code > home > repos > victoriametrics
diff tasks.py @ 67:adde35eb4773
collapse ./next to ./
author | drewp@bigasterisk.com |
---|---|
date | Fri, 03 May 2024 11:21:08 -0700 |
parents | next/tasks.py@429bfd62e6ba |
children | c5e98d891638 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tasks.py Fri May 03 11:21:08 2024 -0700 @@ -0,0 +1,33 @@ +from pathlib import Path + +import yaml +from invoke import task +from kubernetes import config + +import alert_rules +from k8s_ops import firstPodName, refreshPodCmaps, replaceCmap + +config.load_kube_config() + + +def scrapeConfig(fn): + return yaml.load(open(fn), yaml.FullLoader) + + +@task +def push_config(ctx): + # plan: + # every discovered service may: + # - be described here as a forever retention - ignore the discovery + # - be blocked here as a no-metrics service - ignore the discovery + # - be scraped as 'recent', with possible overrides of port/path + # all per-node metrics shall be 'recent' (oops, not smartctl!) + map: dict[str, object] = { + 'rules': alert_rules.allRules(ctx), + } + top = Path('build/scrape_config') + for p in top.glob('*.yaml'): + map[str(p.relative_to(top))] = scrapeConfig(p) + replaceCmap("next-victoriametrics-config", map) + refreshPodCmaps(firstPodName("app=next-victoriametrics-forever-vmagent")) + refreshPodCmaps(firstPodName("app=next-victoriametrics-recent-vmagent"))