Created
May 8, 2019 07:56
-
-
Save HieronyM/10f9ca6eb5e100d858f8b5c00bdf7efa to your computer and use it in GitHub Desktop.
Cloudwatch Agent configuration ansible template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "agent": { | |
| "metrics_collection_interval": 15, | |
| "logfile": "{{ aws_cwa_logfile_path }}" | |
| }, | |
| "metrics": { | |
| "namespace": "CWAgent2", | |
| "metrics_collected": { | |
| "cpu": { | |
| "measurement": [ | |
| {"name": "usage_system", "rename": "CPU Usage System", "unit": "Percent"}, | |
| {"name": "usage_user", "rename": "CPU Usage User", "unit": "Percent"}, | |
| {"name": "usage_idle", "rename": "CPU Usage Idle", "unit": "Percent"} | |
| ] | |
| }, | |
| { | |
| "agent": { | |
| "metrics_collection_interval": 15, | |
| "logfile": "{{ aws_cwa_logfile_path }}" | |
| }, | |
| "metrics": { | |
| "namespace": "CWAgent2", | |
| "metrics_collected": { | |
| "cpu": { | |
| "measurement": [ | |
| {"name": "usage_system", "rename": "CPU Usage System", "unit": "Percent"}, | |
| {"name": "usage_user", "rename": "CPU Usage User", "unit": "Percent"}, | |
| {"name": "usage_idle", "rename": "CPU Usage Idle", "unit": "Percent"} | |
| ] | |
| }, | |
| "mem": { | |
| "measurement": [ | |
| {"name": "total", "rename": "Memory Total"}, | |
| {"name": "available_percent", "rename": "Memory Available", "unit": "Percent"} | |
| ] | |
| } | |
| }, | |
| "aggregation_dimensions" : [["AutoScalingGroupName"], ["InstanceId"],[]] | |
| }{% if aws_cwa_logfiles|length > 0 %}, | |
| "logs": { | |
| "logs_collected": { | |
| "files": { | |
| "collect_list": [ | |
| {% for logfile in aws_cwa_logfiles %} | |
| { | |
| "file_path": "{{ logfile.pathfile }}", | |
| "log_group_name": "{{ logfile.group_name }}", | |
| {% if logfile.stream_name is defined %} | |
| "log_stream_name": "{{ logfile.stream_name }}", | |
| {% endif %} | |
| {% if logfile.timestamp_format is defined %} | |
| "timestamp_format": "{{ logfile.timestamp_format }}" | |
| {% endif %} | |
| {% if logfile.timezone is defined %} | |
| "timezone": "{{ logfile.timezone }}" | |
| {% endif %} | |
| {% if logfile.encoding is defined %} | |
| "encoding": "{{ logfile.encoding }}" | |
| {% endif %} | |
| }{% if not loop.last %},{% endif %} | |
| {% endfor %} | |
| ] | |
| } | |
| } | |
| } | |
| {% endif %} | |
| } | |
| "mem": { | |
| "measurement": [ | |
| {"name": "total", "rename": "Memory Total"}, | |
| {"name": "available_percent", "rename": "Memory Available", "unit": "Percent"} | |
| ] | |
| } | |
| }, | |
| "aggregation_dimensions" : [["AutoScalingGroupName"], ["InstanceId"],[]] | |
| }{% if aws_cwa_logfiles|length > 0 %}, | |
| "logs": { | |
| "logs_collected": { | |
| "files": { | |
| "collect_list": [ | |
| {% for logfile in aws_cwa_logfiles %} | |
| { | |
| "file_path": "{{ logfile.pathfile }}", | |
| "log_group_name": "{{ logfile.group_name }}", | |
| {% if logfile.stream_name is defined %} | |
| "log_stream_name": "{{ logfile.stream_name }}", | |
| {% endif %} | |
| {% if logfile.timestamp_format is defined %} | |
| "timestamp_format": "{{ logfile.timestamp_format }}" | |
| {% endif %} | |
| {% if logfile.timezone is defined %} | |
| "timezone": "{{ logfile.timezone }}" | |
| {% endif %} | |
| {% if logfile.encoding is defined %} | |
| "encoding": "{{ logfile.encoding }}" | |
| {% endif %} | |
| }{% if not loop.last %},{% endif %} | |
| {% endfor %} | |
| ] | |
| } | |
| } | |
| } | |
| {% endif %} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment