Skip to content

Commit 1b295ce

Browse files
committed
Fixups, prepare()
uv run workers/6-gather-postgres.py successfully collects config to db, and empty job_host_summary too
1 parent e060eaa commit 1b295ce

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

workers/6-gather-postgres.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
controller_db = ConnectionHandler({'default': settings.controller_db})['default']
1313
metrics_db = ConnectionHandler({'default': settings.metrics_db})['default']
1414

15+
# Create storage table if it doesn't exist
16+
storage_config = {
17+
'db': metrics_db,
18+
'table': 'metrics_data',
19+
'key_field': 'key',
20+
'value_field': 'value',
21+
'timestamp_field': 'updated_at',
22+
}
23+
24+
library.storage.postgres.create_storage_table(**storage_config)
25+
1526
# Setup PostgreSQL storage using metrics_db
16-
postgres_storage = library.storage.StoragePostgres(
17-
db=metrics_db,
18-
table='metrics_data',
19-
key_field='key',
20-
value_field='value',
21-
timestamp_field='updated_at',
22-
)
27+
postgres_storage = library.storage.StoragePostgres(**storage_config)
2328

2429
# Time range for collectors
2530
since = library.instants.last_day()

workers/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
from dataclasses import dataclass, field
44

5+
from metrics_utility import prepare
6+
7+
8+
prepare()
9+
510

611
@dataclass
712
class Settings:

0 commit comments

Comments
 (0)