From a4cd86193560dd4602e8cfd5ef83811b10279465 Mon Sep 17 00:00:00 2001 From: jmfiola Date: Wed, 10 Jan 2024 11:54:39 -0700 Subject: [PATCH] grafana host parameterization --- README.md | 3 +++ .../lib/configuration/gh_configuration.py | 8 ++++++++ .../lib/fixtures/grasshopper_constants.py | 1 + src/grasshopper/lib/grasshopper.py | 14 ++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/README.md b/README.md index ece5234..ce1c8ee 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,9 @@ you must specify a host. - `--influx_port`: Port for your `influx_host` in the case where it is non-default. - `--influx_user`: Username for your `influx_host`, if you have one. - `--influx_pwd`: Password for your `influx_host`, if you have one. +- `--grafana_host`: If you want to report your performance test metrics to some + grafana, and it is a separate URL from the influxdb, you can specify it here. If you don't, + then the grafana URL will be the same as the influxdb URL.

(back to top)

diff --git a/src/grasshopper/lib/configuration/gh_configuration.py b/src/grasshopper/lib/configuration/gh_configuration.py index e32121d..8eca5e4 100644 --- a/src/grasshopper/lib/configuration/gh_configuration.py +++ b/src/grasshopper/lib/configuration/gh_configuration.py @@ -94,6 +94,14 @@ class ConfigurationConstants: "help": "Password to connect to the influx host.", }, }, + "grafana_host": { + "opts": ["--grafana_host"], + "attrs": { + "action": "store", + "help": "The base grafana url. If not specified, will default to the " + "url that the influxdb/influx_host is set to.", + }, + }, "slack_webhook": { "opts": ["--slack_webhook"], "attrs": { diff --git a/src/grasshopper/lib/fixtures/grasshopper_constants.py b/src/grasshopper/lib/fixtures/grasshopper_constants.py index 9a26153..979e84b 100644 --- a/src/grasshopper/lib/fixtures/grasshopper_constants.py +++ b/src/grasshopper/lib/fixtures/grasshopper_constants.py @@ -17,6 +17,7 @@ class GrasshopperConstants: "influx_port", "influx_user", "influx_pwd", + "grafana_host", "shape_instance", "scenario_delay", "slack_webhook", diff --git a/src/grasshopper/lib/grasshopper.py b/src/grasshopper/lib/grasshopper.py index 96b5c55..4542b49 100644 --- a/src/grasshopper/lib/grasshopper.py +++ b/src/grasshopper/lib/grasshopper.py @@ -67,6 +67,20 @@ def influx_configuration(self) -> dict[str, Optional[str]]: return configuration + @property + def grafana_configuration(self) -> dict[str, Optional[str]]: + """Extract the grafana related configuration items. + + # TODO-DEPRECATED: move this code to the GHConfiguration object + """ + configuration = {} + + host = self.global_configuration.get( + "grafana_host", self.global_configuration.get("influx_host") + ) + configuration["grafana_host"] = host + return configuration + @staticmethod def launch_test( weighted_user_classes: Union[