Skip to content

Commit

Permalink
Collect logstream details from args to support submission-time defini…
Browse files Browse the repository at this point in the history
…tion #1564
  • Loading branch information
iamleeg committed Mar 2, 2022
1 parent 273e108 commit f9b9549
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ingestion/monitoring/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
9 changes: 7 additions & 2 deletions ingestion/monitoring/errorLogsToSlack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import json
import logging
import os
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f9b9549

Please sign in to comment.