Skip to content

Commit

Permalink
fixup! [u] Send GitLab host logs to CloudWatch (#3894)
Browse files Browse the repository at this point in the history
  • Loading branch information
achave11-ucsc committed May 19, 2023
1 parent f61a024 commit a8f7bb0
Showing 1 changed file with 53 additions and 67 deletions.
120 changes: 53 additions & 67 deletions terraform/gitlab/gitlab.tf.json.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'
]
]
]
}
}
Expand Down

0 comments on commit a8f7bb0

Please sign in to comment.