diff --git a/.gitreview b/.gitreview index 45314a6..12f531c 100644 --- a/.gitreview +++ b/.gitreview @@ -2,4 +2,4 @@ host=review.opendev.org port=29418 project=openstack/python-observabilityclient.git -defaultbranch=master +defaultbranch=stable/2025.1 diff --git a/.zuul.yaml b/.zuul.yaml index d26f572..a1cbb9c 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -8,16 +8,24 @@ required-projects: - openstack/python-observabilityclient - openstack/ceilometer - - infrawatch/sg-core + - openstack-k8s-operators/sg-core + - openstack/devstack-plugin-prometheus timeout: 4200 vars: devstack_localrc: USE_PYTHON3: True PROMETHEUS_SERVICE_SCRAPE_TARGETS: prometheus,sg-core CEILOMETER_BACKEND: sg-core + PROMETHEUS_CUSTOM_SCRAPE_TARGETS: "localhost:3000,localhost:9090" devstack_plugins: - sg-core: https://github.com/infrawatch/sg-core + sg-core: https://github.com/openstack-k8s-operators/sg-core ceilometer: https://opendev.org/openstack/ceilometer + devstack-plugin-prometheus: https://opendev.org/openstack/devstack-plugin-prometheus + devstack_services: + node_exporter: false + zuul_copy_output: + /etc/prometheus/prometheus.yml: logs + /etc/openstack/prometheus.yaml: logs - project: queue: telemetry diff --git a/observabilityclient/prometheus_client.py b/observabilityclient/prometheus_client.py index 5380a8d..68483f8 100644 --- a/observabilityclient/prometheus_client.py +++ b/observabilityclient/prometheus_client.py @@ -68,9 +68,12 @@ def set_client_cert(self, client_cert, client_key): def set_basic_auth(self, auth_user, auth_password): self._session.auth = (auth_user, auth_password) + def _get_url(self, endpoint): + scheme = 'https' if self._session.verify else 'http' + return f"{scheme}://{self._host}/api/v1/{endpoint}" # noqa: E231 + def _get(self, endpoint, params=None): - url = (f"{'https' if self._session.verify else 'http'}://" - f"{self._host}/api/v1/{endpoint}") + url = self._get_url(endpoint) resp = self._session.get(url, params=params, headers={'Accept': 'application/json'}) if resp.status_code != requests.codes.ok: @@ -82,8 +85,7 @@ def _get(self, endpoint, params=None): return decoded def _post(self, endpoint, params=None): - url = (f"{'https' if self._session.verify else 'http'}://" - f"{self._host}/api/v1/{endpoint}") + url = self._get_url(endpoint) resp = self._session.post(url, params=params, headers={'Accept': 'application/json'}) if resp.status_code != requests.codes.ok: diff --git a/observabilityclient/tests/functional/test_cli.py b/observabilityclient/tests/functional/test_cli.py index 626be60..4a8c053 100644 --- a/observabilityclient/tests/functional/test_cli.py +++ b/observabilityclient/tests/functional/test_cli.py @@ -88,7 +88,7 @@ def test_show(self): metric["__name__"] ) self.assertEqual( - "sg-core", + "custom", metric["job"] ) @@ -103,7 +103,7 @@ def test_query(self): metric["__name__"] ) self.assertEqual( - "sg-core", + "custom", metric["job"] ) diff --git a/observabilityclient/tests/functional/test_python_api.py b/observabilityclient/tests/functional/test_python_api.py index 8f3bf85..162b7d8 100644 --- a/observabilityclient/tests/functional/test_python_api.py +++ b/observabilityclient/tests/functional/test_python_api.py @@ -52,7 +52,7 @@ def test_show(self): for metric in ret: self.assertEqual("ceilometer_image_size", metric.labels["__name__"]) - self.assertEqual("sg-core", + self.assertEqual("custom", metric.labels["job"]) def test_query(self): @@ -62,7 +62,7 @@ def test_query(self): for metric in ret: self.assertEqual("ceilometer_image_size", metric.labels["__name__"]) - self.assertEqual("sg-core", metric.labels["job"]) + self.assertEqual("custom", metric.labels["job"]) class PythonAPITestFunctionalAdminCommands(base.PythonAPITestCase): diff --git a/observabilityclient/utils/metric_utils.py b/observabilityclient/utils/metric_utils.py index ba70b9a..6b1826b 100644 --- a/observabilityclient/utils/metric_utils.py +++ b/observabilityclient/utils/metric_utils.py @@ -68,7 +68,7 @@ def get_prometheus_client(): if host is None or port is None: raise ConfigurationError("Can't find prometheus host and " "port configuration.") - client = PrometheusAPIClient(f"{host}:{port}") + client = PrometheusAPIClient(f"{host}:{port}") # noqa: E231 if ca_cert is not None: client.set_ca_cert(ca_cert) return client diff --git a/tox.ini b/tox.ini index ec7296b..06da827 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ passenv = PROMETHEUS_* OBSERVABILITY_* deps = - -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt