Mercurial > code > home > repos > victoriametrics
annotate tasks.py @ 65:fada8d64c4d3
notes
author | drewp@bigasterisk.com |
---|---|
date | Thu, 02 May 2024 23:15:37 -0700 |
parents | 84a4c4cca4a5 |
children |
rev | line source |
---|---|
59 | 1 from pathlib import Path |
20 | 2 import yaml |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
3 from invoke import task |
20 | 4 from kubernetes import config |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
5 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
6 import alert_rules |
62
8134cd480817
make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents:
61
diff
changeset
|
7 |
27 | 8 from k8s_ops import firstPodName, refreshPodCmaps, replaceCmap |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
9 |
20 | 10 config.load_kube_config() |
12 | 11 |
12 | |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
13 @task |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
14 def push_config(ctx): |
32
eb1de82c93aa
refactor the merging of all the groups
drewp@bigasterisk.com
parents:
27
diff
changeset
|
15 rulesObj = alert_rules.allRules(ctx) |
10 | 16 |
54 | 17 replaceCmap("victoriametrics-config", { |
18 "scrape_main": scrapeConfig("config/scrape_main.yaml"), | |
58
0064c490c33d
some tiny scrape configs for testing multi-node vmstorage/vmselect
drewp@bigasterisk.com
parents:
54
diff
changeset
|
19 "scrape_recent": scrapeConfig("config/scrape_recent.yaml"), |
0064c490c33d
some tiny scrape configs for testing multi-node vmstorage/vmselect
drewp@bigasterisk.com
parents:
54
diff
changeset
|
20 "scrape_forever": scrapeConfig("config/scrape_forever.yaml"), |
54 | 21 "rules": rulesObj, |
22 }) | |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
23 |
34 | 24 # these don't give errors on rules format! they just quietly keep the old |
25 # rules! use `skaffold run` to get errs. | |
26 # | |
27 # or run | |
28 # validateTemplates = flag.Bool("rule.validateTemplates", true, "Whether to validate annotation and label templates") | |
54 | 29 # validateExpressions = flag.Bool("rule.validateExpressions", true, "Whether to validate rules expressions via MetricsQL engine") |
34 | 30 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
31 refreshPodCmaps(firstPodName("app=victoriametrics")) |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
32 refreshPodCmaps(firstPodName("app=vmalert")) |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
33 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
34 # If the VM reloader isn't fast enough, we could do this too: |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
35 # hup(ctx, 'deploy/victoriametrics', 'victoria-metrics-prod') |
20 | 36 |
37 | |
60
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
38 @task |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
39 def push_config_2024(ctx): |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
40 # plan: |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
41 # every discovered service may: |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
42 # - be described here as a forever retention - ignore the discovery |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
43 # - be blocked here as a no-metrics service - ignore the discovery |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
44 # - be scraped as 'recent', with possible overrides of port/path |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
45 # all per-node metrics shall be 'recent' (oops, not smartctl!) |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
46 map: dict[str, object] = { |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
47 'rules': alert_rules.allRules(ctx), |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
48 } |
61 | 49 top=Path('config/build/scrape_jobs') |
50 for p in top.glob('**/*.yaml'): | |
51 map[str(p.relative_to(top))] = scrapeConfig(p) | |
60
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
52 replaceCmap("next-victoriametrics-config", map) |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
53 refreshPodCmaps(firstPodName("app=next-victoriametrics-forever-vmagent")) |
61 | 54 refreshPodCmaps(firstPodName("app=next-victoriametrics-recent-vmagent")) |
60
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
55 |
e3151ab43579
moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents:
59
diff
changeset
|
56 |
54 | 57 def scrapeConfig(fn): |
58 return yaml.load(open(fn), yaml.FullLoader) | |
59 | 59 |