From: tierno Date: Tue, 21 Jul 2020 12:41:25 +0000 (+0000) Subject: Change lcm.cfg from prometheus to a generic tsdb X-Git-Tag: release-v9.0-start~40 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=991e95d0a27327fe09d1ddfe3e8792df05b8882f;p=osm%2FLCM.git Change lcm.cfg from prometheus to a generic tsdb Include prometheus in the loging configuration Adding tsdb ENV to Dockerfile.local Change-Id: Ib95b33c0eb0deb7bfd2d2baec274d2f442938836 Signed-off-by: tierno --- diff --git a/Dockerfile.local b/Dockerfile.local index d02aee2..40994c0 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -104,6 +104,10 @@ ENV OSMLCM_MESSAGE_DRIVER kafka ENV OSMLCM_MESSAGE_HOST kafka ENV OSMLCM_MESSAGE_PORT 9092 +# tsdb +# ENV OSMLCM_TSDB_DRIVER prometheus +# ENV OSMLCM_TSDB_PATH /etc/prometheus +# ENV OSMLCM_TSDB_URI http://prometheus:9090/ # logs # ENV OSMLCM_GLOBAL_LOGFILE /app/log/lcm.log diff --git a/osm_lcm/lcm.cfg b/osm_lcm/lcm.cfg index 4aadf22..e2e34d4 100644 --- a/osm_lcm/lcm.cfg +++ b/osm_lcm/lcm.cfg @@ -85,10 +85,10 @@ message: # logfile: /var/log/osm/lcm-message.log group_id: lcm-server -prometheus: +tsdb: # time series database driver: prometheus # local file to store the configuration path: /etc/prometheus - uri: http://prometheus:9090/ + uri: http://prometheus:9090/ # loglevel: DEBUG - # logfile: /var/log/osm/lcm-message.log + # logfile: /var/log/osm/lcm-tsdb.log diff --git a/osm_lcm/lcm.py b/osm_lcm/lcm.py index dd7c4ec..eaf2558 100644 --- a/osm_lcm/lcm.py +++ b/osm_lcm/lcm.py @@ -62,6 +62,8 @@ class Lcm: ping_interval_pace = 120 # how many time ping is send once is confirmed all is running ping_interval_boot = 5 # how many time ping is sent when booting + cfg_logger_name = {"message": "lcm.msg", "database": "lcm.db", "storage": "lcm.fs", "tsdb": "lcm.prometheus"} + # ^ contains for each section at lcm.cfg the used logger name def __init__(self, config_file, loop=None): """ @@ -120,7 +122,7 @@ class Lcm: self.logger.setLevel(config["global"]["loglevel"]) # logging other modules - for k1, logname in {"message": "lcm.msg", "database": "lcm.db", "storage": "lcm.fs"}.items(): + for k1, logname in self.cfg_logger_name.items(): config[k1]["logger_name"] = logname logger_module = logging.getLogger(logname) if config[k1].get("logfile"): @@ -190,8 +192,12 @@ class Lcm: # contains created tasks/futures to be able to cancel self.lcm_tasks = TaskRegistry(self.worker_id, self.db, self.logger) - if self.config.get("prometheus"): - self.prometheus = prometheus.Prometheus(self.config["prometheus"], self.worker_id, self.db, self.loop) + if self.config.get("tsdb") and self.config["tsdb"].get("driver"): + if self.config["tsdb"]["driver"] == "prometheus": + self.prometheus = prometheus.Prometheus(self.config["tsdb"], self.worker_id, self.db, self.loop) + else: + raise LcmException("Invalid configuration param '{}' at '[tsdb]':'driver'".format( + config["tsdb"]["driver"])) else: self.prometheus = None self.ns = ns.NsLcm(self.db, self.msg, self.fs, self.lcm_tasks, self.config, self.loop, self.prometheus) @@ -509,7 +515,7 @@ class Lcm: # check RO version self.loop.run_until_complete(self.check_RO_version()) - # configure Prometheus + # configure tsdb prometheus if self.prometheus: self.loop.run_until_complete(self.prometheus.start())