diff --git a/Makefile b/Makefile index e4e6212c2..965e7713a 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ venv-%: install-%: venv-% dev/venv-py$*/bin/pip install --ignore-requires-python --only-binary :all: ruff==0.4.10 # Synchronise this line with .circleci/config.yml - dev/venv-py$*/bin/pip install -r docs/requirements.txt -r dev/requirements.txt -e agent/ -e ui/ psycopg2-binary + dev/venv-py$*/bin/pip install -r docs/requirements.txt -r dev/requirements.txt -e agent/ -e ui/ psycopg2-binary hupper dev/venv-py$*/bin/temboard --version # smoke test dev/venv-py$*/bin/temboard-agent --version # smoke test diff --git a/agent/temboardagent/web/service.py b/agent/temboardagent/web/service.py index b0ccbf9ef..80116a1b2 100644 --- a/agent/temboardagent/web/service.py +++ b/agent/temboardagent/web/service.py @@ -69,6 +69,12 @@ def setup(self): raise UserError(f"Failed to setup SSL: {e}.") self.server.timeout = 1 + logger.info( + "Serving at https://%s:%s.", + self.app.config.temboard.address, + self.app.config.temboard.port, + ) + # for syncio.Loop def accept(self): self.server.handle_request() diff --git a/dev/lnav/formats/temboard_log.json b/dev/lnav/formats/temboard_log.json index e1c168b3a..04d552cc6 100644 --- a/dev/lnav/formats/temboard_log.json +++ b/dev/lnav/formats/temboard_log.json @@ -20,6 +20,9 @@ "systemd": { "pattern": "^(?[.\\w]+): (?.+)$", "module-format": true + }, + "prometheus": { + "pattern": "^ts=(?[^ ]+) caller=.+ level=(?[a-z]{4,}) (?.+)$" } }, "value": { diff --git a/ui/temboardui/toolkit/log.py b/ui/temboardui/toolkit/log.py index 3cb79894e..e9ef87f0f 100644 --- a/ui/temboardui/toolkit/log.py +++ b/ui/temboardui/toolkit/log.py @@ -1,6 +1,7 @@ import datetime import logging import sys +import time from logging.config import dictConfig from logging.handlers import SysLogHandler @@ -132,17 +133,12 @@ def generate_logging_config( stderr_handler = "logging.StreamHandler" if sys.stderr.isatty(): stderr_handler = __name__ + ".ColoredStreamHandler" - timestamp = "%(asctime)s " datefmt = "%H:%M:%S" else: - # strftime does not support milliseconds. Modifying datefmt disables Python hack - # to append milliseconds to timestamp. Thus, hardcode timezone in message format - # rather than datefmt. - timestamp = "%(asctime)s " + localoffset() + " " datefmt = None minimal_fmt = "%(levelname)s: %(lastname)s: %(message)s" - verbose_fmt = timestamp + core + "[%(process)d] " + minimal_fmt + verbose_fmt = "%(asctime)s " + core + "[%(process)d] " + minimal_fmt syslog_fmt = core + "[%(process)d] %(levelname)s: %(lastname)s: %(message)s" logging_config = { @@ -157,7 +153,7 @@ def generate_logging_config( }, "dated_syslog": { "()": __name__ + ".MultilineFormatter", - "format": timestamp + syslog_fmt, + "format": "%(asctime)s " + syslog_fmt, }, "syslog": {"()": __name__ + ".MultilineFormatter", "format": syslog_fmt}, "systemd": { @@ -193,3 +189,9 @@ def localoffset(): hours = offset.seconds // 3600 minutes = (offset.seconds // 60) % 60 return "+%02d%02d" % (hours, minutes) + + +# Make logging format consistent with Prometheus ts= format. +logging.Formatter.converter = time.gmtime +logging.Formatter.default_time_format = "%Y-%m-%dT%H:%M:%S" +logging.Formatter.default_msec_format = "%s.%03dZ" # Append UTC timezone. diff --git a/ui/temboardui/toolkit/services.py b/ui/temboardui/toolkit/services.py index 6194e320a..47809c0a1 100644 --- a/ui/temboardui/toolkit/services.py +++ b/ui/temboardui/toolkit/services.py @@ -195,7 +195,7 @@ def sigchld_handler(self, *a): pass logger.warning( - "Background service dead. Restarting service=%s pid=%s", + "Background service dead. Restarting. service=%s pid=%s", name, self.pids[name], )