annotate tasks.py @ 65:fada8d64c4d3

notes
author drewp@bigasterisk.com
date Thu, 02 May 2024 23:15:37 -0700
parents 84a4c4cca4a5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59
6a357b483c04 migration tasks for new layout
drewp@bigasterisk.com
parents: 58
diff changeset
1 from pathlib import Path
20
f5777b65f035 fast update of scrape_main.yaml
drewp@bigasterisk.com
parents: 15
diff changeset
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
f5777b65f035 fast update of scrape_main.yaml
drewp@bigasterisk.com
parents: 15
diff changeset
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
eec015e90818 reformat
drewp@bigasterisk.com
parents: 22
diff changeset
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
f5777b65f035 fast update of scrape_main.yaml
drewp@bigasterisk.com
parents: 15
diff changeset
10 config.load_kube_config()
12
b6720e379d5b config updates
drewp@bigasterisk.com
parents: 10
diff changeset
11
b6720e379d5b config updates
drewp@bigasterisk.com
parents: 10
diff changeset
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
2023a6ce7bc0 some of the config-rebuild code
drewp@bigasterisk.com
parents: 4
diff changeset
16
54
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
17 replaceCmap("victoriametrics-config", {
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
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
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
21 "rules": rulesObj,
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
22 })
4
1eb6e6a2b9b6 version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff changeset
23
34
3b91d52b007d rules tuning
drewp@bigasterisk.com
parents: 32
diff changeset
24 # these don't give errors on rules format! they just quietly keep the old
3b91d52b007d rules tuning
drewp@bigasterisk.com
parents: 32
diff changeset
25 # rules! use `skaffold run` to get errs.
3b91d52b007d rules tuning
drewp@bigasterisk.com
parents: 32
diff changeset
26 #
3b91d52b007d rules tuning
drewp@bigasterisk.com
parents: 32
diff changeset
27 # or run
3b91d52b007d rules tuning
drewp@bigasterisk.com
parents: 32
diff changeset
28 # validateTemplates = flag.Bool("rule.validateTemplates", true, "Whether to validate annotation and label templates")
54
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
29 # validateExpressions = flag.Bool("rule.validateExpressions", true, "Whether to validate rules expressions via MetricsQL engine")
34
3b91d52b007d rules tuning
drewp@bigasterisk.com
parents: 32
diff changeset
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
f5777b65f035 fast update of scrape_main.yaml
drewp@bigasterisk.com
parents: 15
diff changeset
36
f5777b65f035 fast update of scrape_main.yaml
drewp@bigasterisk.com
parents: 15
diff changeset
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
fb0519859645 better py configs
drewp@bigasterisk.com
parents: 60
diff changeset
49 top=Path('config/build/scrape_jobs')
fb0519859645 better py configs
drewp@bigasterisk.com
parents: 60
diff changeset
50 for p in top.glob('**/*.yaml'):
fb0519859645 better py configs
drewp@bigasterisk.com
parents: 60
diff changeset
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
fb0519859645 better py configs
drewp@bigasterisk.com
parents: 60
diff changeset
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
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
57 def scrapeConfig(fn):
21185db8a52e refactor
drewp@bigasterisk.com
parents: 34
diff changeset
58 return yaml.load(open(fn), yaml.FullLoader)
59
6a357b483c04 migration tasks for new layout
drewp@bigasterisk.com
parents: 58
diff changeset
59