#! /usr/bin/env python import sys from urllib.parse import quote def cwlink(script_name): encoded_filter = quote('{$.info_.script = "' + script_name + '"}') return "".join([ "https://eu-west-1.console.aws.amazon.com/cloudwatch/home?", "region=eu-west-1", "#logEventViewer:", "group=ecs;", "start=PT1H;", "filter={encoded_filter}", ]).format(encoded_filter=encoded_filter) if __name__ == '__main__': try: print(cwlink(sys.argv[1])) except Exception as e: print(e) print("\nUsage: cwlink ") print("Prints the cloudwatch url to filter the log group by that scirpt name.") print("This assumes that the script was ran in the worker, using the script " "on the logger context key.")