From 66840dcb80e1dc066ea3516340676f76f0bf0de3 Mon Sep 17 00:00:00 2001 From: Martin Evgeniev Date: Tue, 19 Feb 2019 13:54:46 +0100 Subject: [PATCH] Improve awslogs Ansible template --- deploy/aws/provision/templates/awslogs.conf.j2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/deploy/aws/provision/templates/awslogs.conf.j2 b/deploy/aws/provision/templates/awslogs.conf.j2 index d2e35829d..8e331444e 100644 --- a/deploy/aws/provision/templates/awslogs.conf.j2 +++ b/deploy/aws/provision/templates/awslogs.conf.j2 @@ -135,7 +135,9 @@ state_file = /var/lib/awslogs/agent-state datetime_format = %b %d %H:%M:%S file = /var/log/messages buffer_duration = 5000 -log_stream_name = {{ ansible_hostname }} +{% if 'type_aws_instance' in group_names %} +log_stream_name = {{ hostvars[inventory_hostname]['tags.Name'] }} +{% endif %} initial_position = start_of_file log_group_name = /var/log/messages @@ -143,6 +145,8 @@ log_group_name = /var/log/messages datetime_format = %b %d %H:%M:%S file = /var/qed/qed.log buffer_duration = 5000 -log_stream_name = {{ ansible_hostname }} +{% if 'type_aws_instance' in group_names %} +log_stream_name = {{ hostvars[inventory_hostname]['tags.Name'] }} +{% endif %} initial_position = start_of_file log_group_name = qed