diff --git a/ingestion/monitoring/Dockerfile b/ingestion/monitoring/Dockerfile index 0ad95442d..812b1f437 100644 --- a/ingestion/monitoring/Dockerfile +++ b/ingestion/monitoring/Dockerfile @@ -66,6 +66,7 @@ COPY errorLogsToSlack.py poetry.lock pyproject.toml ./ # quicker install as runtime deps are already installed RUN poetry install -# notice I haven't set the environment variables here, these -# should be configured at invocation time +# notice I haven't set the environment variables or args here. +# the slack webhook should be configured in the job definition, +# and the args should be configured at submission time CMD ["poetry", "run", "python3", "./errorLogsToSlack.py"] diff --git a/ingestion/monitoring/errorLogsToSlack.py b/ingestion/monitoring/errorLogsToSlack.py index 4ffb4f7a0..c7cdf066a 100644 --- a/ingestion/monitoring/errorLogsToSlack.py +++ b/ingestion/monitoring/errorLogsToSlack.py @@ -1,3 +1,4 @@ +import argparse import json import logging import os @@ -60,8 +61,12 @@ def log_messages(cloudwatch_response, logger): if __name__ == '__main__': logger = setup_logger() - logGroup = os.getenv('INGESTION_LOG_GROUP') - logStream = os.getenv('INGESTION_LOG_STREAM') + parser = argparse.ArgumentParser() + parser.add_argument("group", help="AWS log group name for the failed parser") + parser.add_argument("stream", help="AWS log stream name for the failed parser") + args = parser.parse_args() + logGroup = args.group + logStream = args.stream if logGroup is None or logStream is None: logger.critical(f"Cannot get messages from log group {logGroup} and stream {logStream}") sys.exit(1)