Change lcm.cfg from prometheus to a generic tsdb 10/9510/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 21 Jul 2020 12:41:25 +0000 (12:41 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 23 Jul 2020 07:21:08 +0000 (07:21 +0000)
Include prometheus in the loging configuration
Adding tsdb ENV to Dockerfile.local

Change-Id: Ib95b33c0eb0deb7bfd2d2baec274d2f442938836
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
Dockerfile.local
osm_lcm/lcm.cfg
osm_lcm/lcm.py

index d02aee2..40994c0 100644 (file)
@@ -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
index 4aadf22..e2e34d4 100644 (file)
@@ -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
index dd7c4ec..eaf2558 100644 (file)
@@ -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())