Files
scylladb/test/cluster/dtest/tools/metrics.py
Botond Dénes 87eb20ba33 Merge 'cql: Include parallelized queries in the scylla_cql_select_partition_range_scan_no_bypass_cache metric' from Tomasz Grabiec
This metric is used to catch execution of scans which go via row
cache, which can have bad effect on performance.

Since f344bd0aaa, aggregate queries go
via new statement class: parallelized_select_statement. This class
inherits from select_statement directly rather than from
primary_key_select_statement. The range scan detection logic
(_range_scan, _range_scan_no_bypass_cache) was only in
primary_key_select_statement's constructor, so parallelized queries
were not counted in select_partition_range_scan and
select_partition_range_scan_no_bypass_cache metrics.

Fix by moving the range scan detection into select_statement's
constructor, so that all subclasses get it.

No backport: enhancement

Closes scylladb/scylladb#29422

* github.com:scylladb/scylladb:
  cql: Include parallelized queries in the scylla_cql_select_partition_range_scan_no_bypass_cache metric
  test: cluster: dtest: Fix double-counting of metrics
2026-04-15 14:40:15 +03:00

32 lines
917 B
Python

#
# Copyright (C) 2025-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.1
#
import re
import requests
def prometheus_get(ip, port="9180"):
prometheus_url = f"http://{ip}:{port}/metrics"
resp = requests.get(prometheus_url)
resp.raise_for_status()
return resp.text
def get_node_metrics(node_ip: str, metrics: list[str], port="9180"):
metrics_res = {k: 0 for k in metrics}
filter_metrics = [metric for metric in prometheus_get(node_ip, port).splitlines() if not metric.startswith("#")]
for metric in filter_metrics:
for metric_name in metrics:
if re.search(metric_name + r"[\s{]", metric):
val = metric.split()[-1]
try:
val = int(val)
except ValueError:
val = float(val)
metrics_res[metric_name] += val
return metrics_res