From d0d97d121638a6ad953a544f81842127e5f9a11e Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Wed, 25 May 2022 13:53:55 -0400 Subject: [PATCH 1/2] Added prometheus metrics to pgbench --- snafu/pgbench_wrapper/trigger_pgbench.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/snafu/pgbench_wrapper/trigger_pgbench.py b/snafu/pgbench_wrapper/trigger_pgbench.py index a13fe077..9d79b77d 100644 --- a/snafu/pgbench_wrapper/trigger_pgbench.py +++ b/snafu/pgbench_wrapper/trigger_pgbench.py @@ -171,13 +171,16 @@ def _summarize_data(self, data, iteration, uuid, database, pgb_vers): print("+{}+".format("-" * (115))) def emit_actions(self): + sample_starttime = datetime.utcnow().strftime("%s") output = self._run_pgbench() if output[2] == 1: print("PGBench failed to execute, trying one more time..") + sample_starttime = datetime.utcnow().strftime("%s") output = self._run_pgbench() if output[2] == 1: print("PGBench failed to execute a second time, stopping...") exit(1) + sample_endtime = datetime.utcnow().strftime("%s") data = self._parse_stdout(output[0]) progress = self._parse_stderr(output[1]) documents = self._json_payload(self.meta_processed, data) @@ -200,3 +203,15 @@ def emit_actions(self): if len(documents_prog) > 0: for document in documents_prog: yield document, "results" + sample_info_dict = { + "uuid": self.uuid, + "user": self.user, + "cluster_name": self.cluster_name, + "starttime": sample_starttime, + "endtime": sample_endtime, + "sample": self.run[0], + "tool": "pgbench", + "test_config": self.meta_processed[0], + } + + yield sample_info_dict, "get_prometheus_trigger" From 056090097798203287e39a009e7283c9afebfe52 Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Wed, 20 Jul 2022 08:20:19 -0400 Subject: [PATCH 2/2] Updated PGBench to include number of clients on prom query --- snafu/pgbench_wrapper/trigger_pgbench.py | 1 + 1 file changed, 1 insertion(+) diff --git a/snafu/pgbench_wrapper/trigger_pgbench.py b/snafu/pgbench_wrapper/trigger_pgbench.py index 9d79b77d..5eb373c5 100644 --- a/snafu/pgbench_wrapper/trigger_pgbench.py +++ b/snafu/pgbench_wrapper/trigger_pgbench.py @@ -47,6 +47,7 @@ def __init__(self, args): "run_start_timestamp": self.run_start_timestamp, "sample_start_timestamp": self.sample_start_timestamp, "description": self.description, + "num_clients": int(self.description.split('|')[-1].split(':')[-1].strip()) } )