diff --git a/0006-fix-python3-prometheus-api-client-import-error.patch b/0006-fix-python3-prometheus-api-client-import-error.patch deleted file mode 100644 index a903d07a5392eabd51d62d602d66e3023f57deca..0000000000000000000000000000000000000000 --- a/0006-fix-python3-prometheus-api-client-import-error.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 53cbfd342bcc39a98f0be257a70fefde3fe404eb Mon Sep 17 00:00:00 2001 -From: gongzt -Date: Wed, 18 Oct 2023 17:22:26 +0800 -Subject: fix python3-prometheus-api-client import error -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---- - vulcanus/database/proxy.py | 101 ------------------------------------- - 1 file changed, 101 deletions(-) - -diff --git a/vulcanus/database/proxy.py b/vulcanus/database/proxy.py -index 94e9883..c1ff0fe 100644 ---- a/vulcanus/database/proxy.py -+++ b/vulcanus/database/proxy.py -@@ -24,7 +24,6 @@ import sqlalchemy - from sqlalchemy.exc import SQLAlchemyError, DisconnectionError - from sqlalchemy.orm import sessionmaker - from elasticsearch import Elasticsearch, ElasticsearchException, helpers, TransportError, NotFoundError --from prometheus_api_client import PrometheusConnect, PrometheusApiClientException - import redis - from redis import Redis, ConnectionPool - from vulcanus.log.log import LOGGER -@@ -516,106 +515,6 @@ class ElasticsearchProxy(DataBaseProxy): - return query_body - - --class PromDbProxy(DataBaseProxy): -- """ -- Proxy of prometheus time series database -- """ -- -- def __init__(self, host=None, port=None): -- """ -- Init Prometheus time series database proxy -- -- Args: -- host (str) -- port (int) -- """ -- self._host = host or configuration.prometheus.get('IP') -- self._port = port or configuration.prometheus.get('PORT') -- self._prom = PrometheusConnect(url="http://%s:%s" % (self._host, self._port), disable_ssl=True) -- if not self.connected: -- raise DatabaseConnectionFailed("Promethus connection failed.") -- -- @property -- def connected(self): -- """ -- Make a connect to database connection pool -- -- Returns: -- bool: connect succeed or fail -- """ -- -- return self._prom.check_prometheus_connection() -- -- def query(self, host, time_range, metric, label_config=None): -- """ -- query a metric's data of a host during a time range -- Args: -- host (str): host ip -- time_range (list): list of datetime.datetime -- metric (str): data type of prometheus -- label_config (dict): label config of metric -- -- Returns: -- tuple: (bool, dict) -- """ -- start_time = datetime.fromtimestamp(time_range[0]) -- end_time = datetime.fromtimestamp(time_range[1]) -- -- # metric of a host's all exporters -- # e.g. metric "up" of localhost: up{instance=127.0.0.1\\d{1,5}} -- host_condition = 'instance=~"%s:\\\\d{1,5}"' % host -- combined_condition = PromDbProxy._combine_condition(label_config, host_condition) -- -- metric_with_condition = metric + combined_condition -- -- try: -- data = self._prom.get_metric_range_data( -- metric_name=metric_with_condition, -- start_time=start_time, -- end_time=end_time, -- ) -- -- if not data: -- LOGGER.warning( -- "Query result is empty. Exporter of host %s doesn't record the " "metric '%s' during [%s, %s].", -- host, -- metric, -- start_time, -- end_time, -- ) -- -- return True, data -- -- except (ValueError, TypeError, PrometheusApiClientException) as error: -- LOGGER.error("Prometheus query failed. %s", error) -- failed_item = { -- "host_id": host, -- "name": metric, -- "label": label_config, -- } -- return False, [failed_item] -- -- @staticmethod -- def _combine_condition(label_config, *args): -- """ -- Combine condition together -- Args: -- label_config: label config of metric -- *args (str/list): one or multiple string of condition -- -- Returns: -- str -- """ -- condition_list = list(args) -- -- if label_config: -- for key, value in label_config.items(): -- condition_list.append(str(key) + "=" + '"' + value + '"') -- -- combined_condition = "{" + ",".join(condition_list) + "}" -- return combined_condition -- -- - @singleton - class RedisProxy(DataBaseProxy): - """ --- -2.33.0 - diff --git a/aops-vulcanus.spec b/aops-vulcanus.spec index 2e44f2a4c044972c82c62b5eff371180cd98a341..cd0df85d84ddac5ec195cde5cbd8a7bf93392e12 100644 --- a/aops-vulcanus.spec +++ b/aops-vulcanus.spec @@ -10,7 +10,6 @@ Patch0002: 0002-fix-systemctl-startup-service-error.patch Patch0003: 0003-update-aops-basedatabase.patch Patch0004: 0004-fix-information-path-incorrect.patch Patch0005: 0005-suitable-for-version-2003-sp3.patch -Patch0006: 0006-fix-python3-prometheus-api-client-import-error.patch Patch0007: 0007-update-timed-task-args-check-and-timeout.patch Patch0008: 0008-update-timed-task-args-check.patch @@ -18,7 +17,7 @@ Patch0008: 0008-update-timed-task-args-check.patch BuildRequires: python3-setuptools Requires: python3-concurrent-log-handler python3-xmltodict python3-pyyaml python3-marshmallow >= 3.13.0 Requires: python3-requests python3-xlrd python3-prettytable python3-pygments python3-sqlalchemy -Requires: python3-elasticsearch >= 7 python3-urllib3 python3-werkzeug +Requires: python3-elasticsearch >= 7 python3-prometheus-api-client python3-urllib3 python3-werkzeug Requires: python3-flask python3-flask-restful python3-PyMySQL python3-kafka-python Requires: python-jwt python3-redis python3-Flask-APScheduler >= 1.11.0 Provides: aops-vulcanus @@ -68,7 +67,7 @@ cp -r scripts %{buildroot}/opt/aops/ %changelog -* Tue Nov 07 2023 wenxin - v1.3.0-8 +* Tue Nov 14 2023 wenxin - v1.3.0-8 - update spec file * Wed Oct 25 2023 wenxin - v1.3.0-7