diff --git a/execution/lib/cli_parser.py b/execution/lib/cli_parser.py index 4ab3155e03b51f012f059e0643f5235c48e37bb4..cb4abcabaecf08dd4c7edadd8f1697838dab6970 100644 --- a/execution/lib/cli_parser.py +++ b/execution/lib/cli_parser.py @@ -50,6 +50,10 @@ def default_parser(description): parser.add_argument('--reset-only', action="store_true", help='Only resets the environment. Ignores all other parameters') + parser.add_argument('--prometheus', + metavar='<URL>', + default=os.environ.get('PROMETHEUS_BASE_URL'), + help='Defines where to find the prometheus instance') return parser def benchmark_parser(description): diff --git a/execution/run_uc.py b/execution/run_uc.py index 3b46c50acbf383cef74cfe41dea025928fb6e4ad..8cd6f0621b089f0384b8173d01de7748cb29b423 100644 --- a/execution/run_uc.py +++ b/execution/run_uc.py @@ -4,7 +4,7 @@ from kubernetes import client, config # kubernetes api from kubernetes.stream import stream import lag_analysis import logging # logging -from os import path # path utilities +from os import path, environ # path utilities from lib.cli_parser import execution_parser import subprocess # execute bash commands import sys # for exit of program @@ -244,7 +244,7 @@ def wait_execution(execution_minutes): return -def run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes): +def run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes, prometheus_base_url=None): """ Runs the evaluation function :param string exp_id: ID of the experiment. @@ -254,7 +254,12 @@ def run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes): :param int execution_minutes: How long the use case where executed. """ print('Run evaluation function') - lag_analysis.main(exp_id, f'uc{uc_id}', dim_value, instances, execution_minutes) + if prometheus_base_url is None and environ.get('PROMETHEUS_BASE_URL') is None: + lag_analysis.main(exp_id, f'uc{uc_id}', dim_value, instances, execution_minutes) + elif prometheus_base_url is not None: + lag_analysis.main(exp_id, f'uc{uc_id}', dim_value, instances, execution_minutes, prometheus_base_url) + else: + lag_analysis.main(exp_id, f'uc{uc_id}', dim_value, instances, execution_minutes, environ.get('PROMETHEUS_BASE_URL')) return @@ -449,7 +454,7 @@ def reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics): stop_lag_exporter() -def main(exp_id, uc_id, dim_value, instances, partitions, cpu_limit, memory_limit, commit_interval_ms, execution_minutes, reset, reset_only): +def main(exp_id, uc_id, dim_value, instances, partitions, cpu_limit, memory_limit, commit_interval_ms, execution_minutes, prometheus_base_url=None, reset=False, reset_only=False): """ Main method to execute one time the benchmark for a given use case. Start workload generator/application -> execute -> analyse -> stop all @@ -514,7 +519,7 @@ def main(exp_id, uc_id, dim_value, instances, partitions, cpu_limit, memory_limi wait_execution(execution_minutes) print('---------------------') - run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes) + run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes, prometheus_base_url) print('---------------------') # Reset cluster regular, therefore abort exit not needed anymore @@ -528,5 +533,5 @@ if __name__ == '__main__': print('---------------------') main(args.exp_id, args.uc, args.load, args.instances, args.partitions, args.cpu_limit, args.memory_limit, - args.commit_ms, args.duration, args.reset, + args.commit_ms, args.duration, args.prometheus, args.reset, args.reset_only)