From 8e314eea9432f415dcd15eebb4a0616f9a1506f9 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sat, 12 Nov 2022 02:15:25 +1100 Subject: [PATCH] Collect metrics for chat_archiver on port 8008 --- chat_archiver/chat_archiver/main.py | 4 +++- docker-compose.jsonnet | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/chat_archiver/chat_archiver/main.py b/chat_archiver/chat_archiver/main.py index 4844086..ef15b88 100644 --- a/chat_archiver/chat_archiver/main.py +++ b/chat_archiver/chat_archiver/main.py @@ -380,7 +380,7 @@ def merge_batch_files(path, batch_time): os.remove(batch_file) -def main(channel, nick, oauth_token_path, base_dir='/mnt', name=None, merge_interval=60): +def main(channel, nick, oauth_token_path, base_dir='/mnt', name=None, merge_interval=60, metrics_port=8008): with open(oauth_token_path) as f: oauth_token = f.read() # To ensure uniqueness even if multiple instances are running on the same host, @@ -399,6 +399,8 @@ def main(channel, nick, oauth_token_path, base_dir='/mnt', name=None, merge_inte stopping=stopping ) + prom.start_http_server(metrics_port) + logging.info("Starting") for index in count(): # To ensure uniqueness between clients, include a client number diff --git a/docker-compose.jsonnet b/docker-compose.jsonnet index de17759..9be767d 100644 --- a/docker-compose.jsonnet +++ b/docker-compose.jsonnet @@ -67,6 +67,7 @@ sheetsync: 8005, segment_coverage: 8006, playlist_manager: 8007, + chat_archiver: 8008, nginx: 80, nginx_ssl: 443, postgres: 5432, @@ -407,6 +408,7 @@ sheetsync: 8005, segment_coverage: 8006, playlist_manager: 8007, + chat_archiver: 8008, }, image: $.get_image("nginx"), restart: "on-failure", @@ -457,6 +459,8 @@ restart: "always", command: [$.chat_archiver.channel, $.chat_archiver.user, "/token", "--name", $.localhost], volumes: ["%s:/mnt" % $.segments_path, "%s:/token" % $.chat_archiver.token_path], + [if "chat_archiver" in $.ports then "ports"]: ["%s:8008" % $.ports.chat_archiver], + environment: $.env, }, },