diff --git a/README.md b/README.md index 3a341a9..579e515 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,12 @@ Default: `undef` Optional. This is a regex string that identifies the start of a log line. See [the official docs](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/AgentReference.html) for further info. +#### `file_fingerprint_lines` + +Default: `1` + +Optional. Specifies the range of lines for identifying a file. The valid values are one number or two dash delimited numbers, such as '1', '2-5'. The default value is '1' so the first line is used to calculate fingerprint. Fingerprint lines are not sent to CloudWatch Logs unless all the specified lines are available. + ## Http Proxy Usage If you have a http_proxy or https_proxy then run the following puppet code after calling cloudwatchlogs to modify the launcher script as a workaround bcause awslogs python code currently doesn't have http_proxy support: diff --git a/manifests/compartment_log.pp b/manifests/compartment_log.pp index 0e765e1..534f47d 100644 --- a/manifests/compartment_log.pp +++ b/manifests/compartment_log.pp @@ -1,9 +1,10 @@ define cloudwatchlogs::compartment_log ( - $path = undef, - $streamname = '{instance_id}', - $datetime_format = '%b %d %H:%M:%S', - $log_group_name = undef, + $path = undef, + $streamname = '{instance_id}', + $datetime_format = '%b %d %H:%M:%S', + $log_group_name = undef, $multi_line_start_pattern = undef, + $file_fingerprint_lines = undef, ){ if $path == undef { @@ -22,6 +23,7 @@ validate_string($datetime_format) validate_string($real_log_group_name) validate_string($multi_line_start_pattern) + validate_string($file_fingerprint_lines) $installed_marker = $::operatingsystem ? { 'Amazon' => Package['awslogs'], diff --git a/manifests/init.pp b/manifests/init.pp index 0adf945..d5c050b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -80,12 +80,12 @@ path => '/etc/awslogs/awscli.conf', line => "region = ${region}", match => '^region\s*=', - notify => Service['awslogs'], + notify => Service[$service_name], require => Package['awslogs'], } } - service { 'awslogs': + service { $service_name: ensure => 'running', enable => true, hasrestart => true, @@ -163,13 +163,13 @@ Exec['cloudwatchlogs-wget'] ], before => [ - Service['awslogs'], + Service[$service_name], File['/var/awslogs/etc/awslogs.conf'], ] } } - service { 'awslogs': + service { $service_name: ensure => 'running', enable => true, hasrestart => true, @@ -188,7 +188,7 @@ group => 'root', mode => '0644', content => template('cloudwatchlogs/awslogs_logging_config_file.erb'), - notify => Service['awslogs'], + notify => Service[$service_name], require => $installed_marker, } } diff --git a/manifests/log.pp b/manifests/log.pp index 585ebf4..b5900d4 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -1,9 +1,10 @@ define cloudwatchlogs::log ( - $path = undef, - $streamname = '{instance_id}', - $datetime_format = '%b %d %H:%M:%S', - $log_group_name = undef, + $path = undef, + $streamname = '{instance_id}', + $datetime_format = '%b %d %H:%M:%S', + $log_group_name = undef, $multi_line_start_pattern = undef, + $file_fingerprint_lines = undef, ){ if $path == undef { @@ -22,6 +23,7 @@ validate_string($datetime_format) validate_string($real_log_group_name) validate_string($multi_line_start_pattern) + validate_string($file_fingerprint_lines) concat::fragment { "cloudwatchlogs_fragment_${name}": target => '/etc/awslogs/awslogs.conf', diff --git a/manifests/params.pp b/manifests/params.pp index c737817..6fab0c6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,6 +4,14 @@ 'Amazon': { $state_file = '/var/lib/awslogs/agent-state' } default: { $state_file = '/var/awslogs/state/agent-state' } } + $osname = $facts['os']['name'] + $osmajor = $facts['os']['release']['major'] + $oslong = "${osname}${osmajor}" + + case $oslong { + 'Amazon2': { $service_name = 'awslogsd' } + default: { $service_name = 'awslogs' } + } $logging_config_file = '/etc/awslogs/awslogs_dot_log.conf' $region = undef $log_level = undef diff --git a/templates/awslogs_log.erb b/templates/awslogs_log.erb index 97ab743..5a59b2d 100644 --- a/templates/awslogs_log.erb +++ b/templates/awslogs_log.erb @@ -7,4 +7,7 @@ initial_position = start_of_file log_group_name = <%= @real_log_group_name %> <% if @multi_line_start_pattern -%> multi_line_start_pattern = <%= @multi_line_start_pattern %> +<% end -%> +<% if @file_fingerprint_lines -%> +file_fingerprint_lines = <%= @file_fingerprint_lines %> <% end %>