Skip to content

Commit 15b3c38

Browse files
committed
Query Collector: Make table schema configurable
1 parent cf91fb8 commit 15b3c38

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cratedb_toolkit/wtf/query_collector.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
logger = logging.getLogger(__name__)
1717

1818
cratedb_sqlalchemy_url = os.getenv("CRATEDB_SQLALCHEMY_URL", "crate://crate@localhost:4200")
19-
uri = DatabaseAddress.from_string(cratedb_sqlalchemy_url)
20-
host = f"{uri.uri.host}:{uri.uri.port}"
21-
username = uri.uri.username
22-
password = uri.uri.password
19+
address = DatabaseAddress.from_string(cratedb_sqlalchemy_url)
20+
host = f"{address.uri.host}:{address.uri.port}"
21+
username = address.uri.username
22+
password = address.uri.password
23+
_, table_address = address.decode()
24+
schema = table_address.schema or "stats"
25+
2326
interval = float(os.getenv("INTERVAL", 10))
24-
stmt_log_table = os.getenv("STMT_TABLE", "stats.statement_log")
25-
last_exec_table = os.getenv("LAST_EXEC_TABLE", "stats.last_execution")
27+
stmt_log_table = os.getenv("STMT_TABLE", f"{schema}.statement_log")
28+
last_exec_table = os.getenv("LAST_EXEC_TABLE", f"{schema}.last_execution")
2629
last_execution_ts = 0
2730
sys_jobs_log = {}
2831
bucket_list = [10, 50, 100, 500, 1000, 2000, 5000, 10000, 15000, 20000]

0 commit comments

Comments
 (0)