diff --git a/terraform/gitlab/gitlab.tf.json.template.py b/terraform/gitlab/gitlab.tf.json.template.py index e683b86822..11d15185d1 100644 --- a/terraform/gitlab/gitlab.tf.json.template.py +++ b/terraform/gitlab/gitlab.tf.json.template.py @@ -1542,18 +1542,13 @@ def qq(*words): ) }, { - # AWS recommends placing the amazon-cloudwatch-agent config file in this path. - # The amazon-cloudwatch-agent package is also installed in this directory. + # AWS recommends placing the amazon-cloudwatch-agent config file at this path. + # Note that the parent of etc/ is where the agent is installed. 'path': '/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json', 'permissions': '0664', 'owner': 'root', 'content': json.dumps({ 'agent': { - # This is the frequency interval, in seconds, of the agent's file collection. - # Anything sub-sixty seconds is considered high-resolution data, which provides - # more inmediate insight in sub-minute activity. In this case the default, 60s, - # is the smallest standard resolution interval. - 'metrics_collection_interval': 60, 'region': aws.region_name, 'logfile': '/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log', 'debug': bool(config.debug) @@ -1563,69 +1558,60 @@ def qq(*words): 'files': { 'collect_list': [ { - # The '*' is used in order to get the most recent GitLab reconfigure - # logs (name based on UNIX timestamp of when reconfigure initiated). - # Only the most recent file, by modification time, matching the - # wildcard is collected. - 'file_path': '/mnt/gitlab/logs/reconfigure/*.log', + 'file_path': path, 'log_group_name': '/aws/cwagent/azul-gitlab', - 'log_stream_name': '/mnt/gitlab/logs/reconfigure/dated.log' - }, - *( - { - 'file_path': logfile_path, - 'log_group_name': '/aws/cwagent/azul-gitlab', - 'log_stream_name': logfile_path - } - for logfile_path in + 'log_stream_name': + path if not path.endswith('*.log') + else path.replace('*', 'reconfigure') + } + for path in + [ + f'/mnt/gitlab/logs/{file}.log' + for file in [ - *[ - f'/mnt/gitlab/logs/{file}.log' - for file in - [ - 'gitaly/gitaly_ruby_json', - 'gitlab-shell/gitlab-shell', - 'nginx/gitlab_access', - 'nginx/gitlab_error', - 'nginx/gitlab_registry_access', - 'puma/puma_stderr', - 'puma/puma_stdout' - ] - ], - *[ - f'/mnt/gitlab/logs/gitlab-rails/{file}.log' - for file in - [ - 'api_json', - 'application_json', - 'application', - 'audit_json', - 'auth', - 'database_load_balancing', - 'exceptions_json', - 'gitlab-shell', - 'graphql_json', - 'migrations', - 'production_json', - 'production', - 'sidekiq_client' - ] - ], - *[ - f'/var/log/{file}' - for file in - [ - 'amazon/ssm/amazon-ssm-agent.log', - 'audit/audit.log', - 'cloud-init.log', - 'cron', - 'maillog', - 'messages', - 'secure' - ] - ] + 'gitaly/gitaly_ruby_json', + 'gitlab-shell/gitlab-shell', + 'nginx/gitlab_access', + 'nginx/gitlab_error', + 'nginx/gitlab_registry_access', + 'puma/puma_stderr', + 'puma/puma_stdout', + # The '*' is used in order to get the most recent GitLab + # reconfigure logs (name based on UNIX timestamp of when + # reconfigure initiated). Only the most recent file, by + # modification time, matching the wildcard is collected. + 'reconfigure/*.log' ] - ) + ] + [ + f'/mnt/gitlab/logs/gitlab-rails/{file}.log' + for file in + [ + 'api_json', + 'application_json', + 'application', + 'audit_json', + 'auth', + 'database_load_balancing', + 'exceptions_json', + 'graphql_json', + 'migrations', + 'production_json', + 'production', + 'sidekiq_client' + ] + ] + [ + f'/var/log/{file}' + for file in + [ + 'amazon/ssm/amazon-ssm-agent.log', + 'audit/audit.log', + 'cloud-init.log', + 'cron', + 'maillog', + 'messages', + 'secure' + ] + ] ] } }