Mercurial > code > home > repos > victoriametrics
annotate tasks.py @ 68:c5e98d891638
remove 'next' prefix
author | drewp@bigasterisk.com |
---|---|
date | Fri, 03 May 2024 11:32:24 -0700 |
parents | adde35eb4773 |
children | 68164135ae66 |
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 |
66
429bfd62e6ba
clean out old config; move remaining bits into next/
drewp@bigasterisk.com
parents:
64
diff
changeset
|
18 def push_config(ctx): |
62
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) |
68 | 31 replaceCmap("victoriametrics-config", map) |
32 refreshPodCmaps(firstPodName("app=victoriametrics-forever-vmagent")) | |
33 refreshPodCmaps(firstPodName("app=victoriametrics-recent-vmagent")) |