Mercurial > code > home > repos > victoriametrics
comparison tasks.py @ 59:6a357b483c04
migration tasks for new layout
author | drewp@bigasterisk.com |
---|---|
date | Fri, 26 Apr 2024 23:37:14 -0700 |
parents | 0064c490c33d |
children | e3151ab43579 |
comparison
equal
deleted
inserted
replaced
58:0064c490c33d | 59:6a357b483c04 |
---|---|
1 from pathlib import Path | |
1 import yaml | 2 import yaml |
2 from invoke import task | 3 from invoke import task |
3 from kubernetes import config | 4 from kubernetes import config |
4 | 5 |
5 import alert_rules | 6 import alert_rules |
33 # hup(ctx, 'deploy/victoriametrics', 'victoria-metrics-prod') | 34 # hup(ctx, 'deploy/victoriametrics', 'victoria-metrics-prod') |
34 | 35 |
35 | 36 |
36 def scrapeConfig(fn): | 37 def scrapeConfig(fn): |
37 return yaml.load(open(fn), yaml.FullLoader) | 38 return yaml.load(open(fn), yaml.FullLoader) |
39 | |
40 | |
41 metricsToMigrate = [ | |
42 'house_power_kwh', | |
43 'house_power_price', | |
44 'house_power_w', | |
45 'lan_bytes_sent_from_created', | |
46 'lan_bytes_sent_from_total', | |
47 'lan_last_seen_time', | |
48 'maildir_count', | |
49 'mongodb_mongod_db_coll_avgobjsize', | |
50 'mongodb_mongod_db_coll_count', | |
51 'mongodb_mongod_db_coll_index_size', | |
52 'mongodb_mongod_db_coll_indexes', | |
53 'mongodb_mongod_db_coll_indexes_size', | |
54 'mongodb_mongod_db_coll_size', | |
55 'mongodb_mongod_db_coll_storage_size', | |
56 'mongodb_mongod_db_collections_total', | |
57 'mongodb_mongod_db_data_size_bytes', | |
58 'mongodb_mongod_db_index_size_bytes', | |
59 'mongodb_mongod_db_indexes_total', | |
60 'mongodb_mongod_db_objects_total', | |
61 'probe_duration_seconds', | |
62 'smartctl_device', | |
63 'smartctl_device_attribute', | |
64 'smartctl_device_available_spare', | |
65 'smartctl_device_available_spare_threshold', | |
66 'smartctl_device_block_size', | |
67 'smartctl_device_bytes_read', | |
68 'smartctl_device_bytes_written', | |
69 'smartctl_device_capacity_blocks', | |
70 'smartctl_device_capacity_bytes', | |
71 'smartctl_device_critical_warning', | |
72 'smartctl_device_interface_speed', | |
73 'smartctl_device_media_errors', | |
74 'smartctl_device_num_err_log_entries', | |
75 'smartctl_device_percentage_used', | |
76 'smartctl_device_power_cycle_count', | |
77 'smartctl_device_power_on_seconds', | |
78 'smartctl_device_smart_status', | |
79 'smartctl_device_smartctl_exit_status', | |
80 'smartctl_device_status', | |
81 'smartctl_device_temperature', | |
82 'zfs_dataset_logical_used_bytes', | |
83 'zfs_dataset_referenced_bytes', | |
84 'zfs_dataset_used_by_dataset_bytes', | |
85 'zfs_dataset_used_bytes', | |
86 'zfs_dataset_written_bytes', | |
87 'zfs_exporter_build_info', | |
88 'zfs_pool_allocated_bytes', | |
89 'zfs_pool_deduplication_ratio', | |
90 'zfs_pool_fragmentation_ratio', | |
91 'zfs_pool_free_bytes', | |
92 'zfs_pool_freeing_bytes', | |
93 'zfs_pool_health', | |
94 'zfs_pool_leaked_bytes', | |
95 'zfs_pool_readonly', | |
96 'zfs_pool_size_bytes', | |
97 'zfs_scrape_collector_duration_seconds', | |
98 'zfs_scrape_collector_success', | |
99 'zigbee_availability', | |
100 'zigbee_battery', | |
101 'zigbee_brightness', | |
102 'zigbee_contact', | |
103 'zigbee_link_quality', | |
104 'zigbee_occupancy', | |
105 'zpool_device_error_count', | |
106 'zpool_device_state', | |
107 'zpool_error_count', | |
108 'zpool_state', | |
109 ] | |
110 | |
111 | |
112 @task | |
113 def exportForeverMetrics(ctx): | |
114 svc = ctx.run('khost victoriametrics').stdout | |
115 for m in metricsToMigrate: | |
116 ctx.run(f'curl http://{svc}/m/api/v1/export/native?match={m} | gzip -c > export/{m}.native.gz') | |
117 | |
118 | |
119 @task | |
120 def ingestForeverMetrics(ctx): | |
121 svc = ctx.run('khost next-victoriametrics-forever-vminsert').stdout | |
122 for p in Path('export').glob('*.native.gz'): | |
123 print(f'importing {p}') | |
124 ctx.run(f'zcat {p} | curl -s http://{svc}/m/next/forever/vminsert/insert/0/prometheus/api/v1/import/native --data-binary @-') |