mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 00:43:06 -06:00
DCD-436: Make log group unique.
This commit is contained in:
@@ -6,3 +6,5 @@ aws_cloudwatch_agent_rpm: "https://s3.{{ aws_download_region }}.amazonaws.com/am
|
||||
|
||||
# Mostly for molecule testing, as skip-tags doesn't work with handlers.
|
||||
atl_aws_agent_restart: true
|
||||
|
||||
atl_aws_log_group: "{{ atl_product_edition }}-{{ atl_aws_stack_name }}"
|
||||
|
||||
@@ -8,13 +8,19 @@ lint:
|
||||
platforms:
|
||||
- name: amazon_linux2
|
||||
image: amazonlinux:2
|
||||
groups:
|
||||
- aws_node_local
|
||||
# - name: ubuntu_lts
|
||||
# image: ubuntu:bionic
|
||||
provisioner:
|
||||
name: ansible
|
||||
lint:
|
||||
name: ansible-lint
|
||||
inventory:
|
||||
links:
|
||||
group_vars: ../../../../group_vars/
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
enabled: false
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
ansible_default_ipv4:
|
||||
address: "9.9.9.9"
|
||||
ansible_ec2_instance_id: "NONE"
|
||||
|
||||
atl_product_family: "jira"
|
||||
atl_product_edition: "jira-software"
|
||||
atl_aws_stack_name: "MY_STACK"
|
||||
|
||||
atl_aws_agent_restart: false
|
||||
roles:
|
||||
- role: aws_common
|
||||
|
||||
@@ -15,3 +15,11 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
])
|
||||
def test_package_exes(host, exe):
|
||||
assert host.file(exe).exists
|
||||
|
||||
|
||||
def test_service_file(host):
|
||||
f = host.file('/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json')
|
||||
assert f.contains('"log_group_name": "jira-software-MY_STACK"')
|
||||
assert f.user == 'root'
|
||||
assert f.group == 'root'
|
||||
assert f.mode == 0o0644
|
||||
|
||||
@@ -12,3 +12,13 @@
|
||||
set_fact:
|
||||
atl_cluster_node_id: "{{ ansible_ec2_instance_id }}"
|
||||
atl_local_ipv4: "{{ ansible_ec2_local_ipv4 | default(ansible_default_ipv4.address) }}"
|
||||
|
||||
- name: Generate CloudWatch config
|
||||
template:
|
||||
src: "amazon-cloudwatch-agent.json.j2"
|
||||
dest: "/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- Restart CloudWatch Agent
|
||||
|
||||
88
roles/aws_common/templates/amazon-cloudwatch-agent.json.j2
Normal file
88
roles/aws_common/templates/amazon-cloudwatch-agent.json.j2
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"agent": {
|
||||
"metrics_collection_interval": 10,
|
||||
"run_as_user": "root"
|
||||
},
|
||||
|
||||
"logs": {
|
||||
"logs_collected": {
|
||||
"files": {
|
||||
"collect_list": [
|
||||
{% set comma = joiner(',') %}
|
||||
{% for path in atl_product_log_locations[atl_product_family] %}
|
||||
{{ comma() }}
|
||||
{
|
||||
"file_path": "{{ path }}/*",
|
||||
"log_group_name": "{{ atl_aws_log_group }}",
|
||||
"log_stream_name": "{instance_id}"
|
||||
}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"metrics": {
|
||||
"append_dimensions": {
|
||||
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
|
||||
"ImageId": "${aws:ImageId}",
|
||||
"InstanceId": "${aws:InstanceId}",
|
||||
"InstanceType": "${aws:InstanceType}"
|
||||
},
|
||||
"metrics_collected": {
|
||||
"cpu": {
|
||||
"measurement": [
|
||||
"cpu_usage_idle",
|
||||
"cpu_usage_iowait",
|
||||
"cpu_usage_user",
|
||||
"cpu_usage_system"
|
||||
],
|
||||
"metrics_collection_interval": 10,
|
||||
"totalcpu": false
|
||||
},
|
||||
"disk": {
|
||||
"measurement": [
|
||||
"used_percent",
|
||||
"inodes_free"
|
||||
],
|
||||
"metrics_collection_interval": 10,
|
||||
"resources": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
"diskio": {
|
||||
"measurement": [
|
||||
"io_time",
|
||||
"write_bytes",
|
||||
"read_bytes",
|
||||
"writes",
|
||||
"reads"
|
||||
],
|
||||
"metrics_collection_interval": 10,
|
||||
"resources": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
"mem": {
|
||||
"measurement": [
|
||||
"mem_used_percent"
|
||||
],
|
||||
"metrics_collection_interval": 10
|
||||
},
|
||||
"netstat": {
|
||||
"measurement": [
|
||||
"tcp_established",
|
||||
"tcp_time_wait"
|
||||
],
|
||||
"metrics_collection_interval": 10
|
||||
},
|
||||
"swap": {
|
||||
"measurement": [
|
||||
"swap_used_percent"
|
||||
],
|
||||
"metrics_collection_interval": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user