Mercurial > code > home > repos > victoriametrics
annotate next/tasks.py @ 64:def1aa2bfa3f
more targets polish. reorg code into next/
author | drewp@bigasterisk.com |
---|---|
date | Thu, 02 May 2024 23:06:31 -0700 |
parents | 8134cd480817 |
children | 429bfd62e6ba |
rev | line source |
---|---|
62
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
1 from pathlib import Path |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
2 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
3 import yaml |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
4 from invoke import task |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
5 from kubernetes import config |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
6 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
7 import alert_rules |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
8 from k8s_ops import firstPodName, refreshPodCmaps, replaceCmap |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
9 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
10 config.load_kube_config() |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
11 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
12 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
13 def scrapeConfig(fn): |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
14 return yaml.load(open(fn), yaml.FullLoader) |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
15 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
16 |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
17 @task |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
18 def push_config_2024(ctx): |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
19 # plan: |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
20 # every discovered service may: |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
21 # - be described here as a forever retention - ignore the discovery |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
22 # - be blocked here as a no-metrics service - ignore the discovery |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
23 # - be scraped as 'recent', with possible overrides of port/path |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
24 # all per-node metrics shall be 'recent' (oops, not smartctl!) |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
25 map: dict[str, object] = { |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
26 'rules': alert_rules.allRules(ctx), |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
27 } |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
28 top = Path('build/scrape_config') |
64
def1aa2bfa3f
more targets polish. reorg code into next/
drewp@bigasterisk.com
parents:
62
diff
changeset
|
29 for p in top.glob('*.yaml'): |
62
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
30 map[str(p.relative_to(top))] = scrapeConfig(p) |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
31 replaceCmap("next-victoriametrics-config", map) |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
32 refreshPodCmaps(firstPodName("app=next-victoriametrics-forever-vmagent")) |
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
diff
changeset
|
33 refreshPodCmaps(firstPodName("app=next-victoriametrics-recent-vmagent")) |