Skip to content

Commit 9093cfd

Browse files
committed
Metrics: fetch application metrics only for matching components
1 parent 65d046a commit 9093cfd

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

dbmsbenchmarker/monitor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def generateLatexForQuery(self, parameter):
238238
else:
239239
return ""
240240
@staticmethod
241-
def fetchMetric(query, metric_code, connection, connectiondata, time_start, time_end, path, container=None, metrics_query_path='metrics'):
241+
def fetchMetric(query, metric_code, connection, connectiondata, time_start, time_end, path, container=None, metrics_query_path='metrics', component=''):
242242
# metrics_query_path = where to find the promql paths in connectiondata (metrics for components managed by bexhoma, metrics_special otherwise)
243243
#for m, metric in metrics.metrics.items():
244244
logging.debug("Metric "+metric_code)
@@ -262,6 +262,9 @@ def fetchMetric(query, metric_code, connection, connectiondata, time_start, time
262262
if not active:
263263
df = pd.DataFrame()
264264
return df
265+
if len(component) > 0 and 'component' in metric and metric['component'] != component:
266+
df = pd.DataFrame()
267+
return df
265268
#print(metric)
266269
if container is not None:
267270
metric['query'] = metric['query'].replace('container_label_io_kubernetes_container_name="dbms"', 'container_label_io_kubernetes_container_name="{}"'.format(container))

metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
parser.add_argument('-f', '--config-folder', help='folder containing query and connection config files. If set, the names connections.config and queries.config are assumed automatically.', default=None)
3737
parser.add_argument('-c', '--connection', help='Name of the connection (dbms) to use', default=None)
3838
parser.add_argument('-mt', '--metrics-type', help='Type of metrics definitions (metrics, metrics_special, metrics_custom)', default='')
39-
#parser.add_argument('-co', '--component', help='Component name', default='sut')
39+
parser.add_argument('-com', '--component', help='Component name', default='')
4040
parser.add_argument('-ct', '--component-type', help='Type of the component (loading or stream)', default='loading')
4141
parser.add_argument('-cn', '--container-name', help='Name of the container (if not dbms for sut/workers: datagenerator, sensor, dbmsbenchmarker)', default=None)
4242
parser.add_argument('-cf', '--connection-file', help='name of connection config file', default='connections.config')
@@ -54,7 +54,7 @@
5454
connection = args.connection
5555
query = args.component_type
5656
metrics_type = args.metrics_type
57-
#component = args.component
57+
component = args.component
5858
container_name = args.container_name
5959
time_start = int(args.time_start)#1616083225
6060
time_end = int(args.time_end)#1616083310
@@ -92,7 +92,7 @@
9292
for m, metric in connection_data.connectiondata['monitoring'][metrics_type].items():
9393
print("Metric", m)
9494
path = '{result_path}/{code}/'.format(result_path=result_path, code=code)
95-
monitor.metrics.fetchMetric(query, m, connection_name, connection_data.connectiondata, time_start, time_end, path, container=container_name, metrics_query_path=metrics_type)
95+
monitor.metrics.fetchMetric(query, m, connection_name, connection_data.connectiondata, time_start, time_end, path, container=container_name, metrics_query_path=metrics_type, component=component)
9696
# do not use replacement anymore (SUT deployment replaced by SUT worker)
9797
#elif 'metrics_special' in connection_data.connectiondata['monitoring'] and (query == 'loading' or query == 'stream'):
9898
# print("Use special metrics for SUT not managed by bexhoma: component type = {}".format(query))
@@ -105,7 +105,7 @@
105105
for m, metric in connection_data.connectiondata['monitoring']['metrics'].items():
106106
print("Metric", m)
107107
path = '{result_path}/{code}/'.format(result_path=result_path, code=code)
108-
monitor.metrics.fetchMetric(query, m, connection_name, connection_data.connectiondata, time_start, time_end, path, container=container_name, metrics_query_path='metrics')
108+
monitor.metrics.fetchMetric(query, m, connection_name, connection_data.connectiondata, time_start, time_end, path, container=container_name, metrics_query_path='metrics', component=component)
109109
#metrics = monitor.metrics(experiments)
110110
#df = metrics.dfHardwareMetricsLoading(m)
111111
#print(df)

0 commit comments

Comments
 (0)