Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions manifests/compartment_log.pp
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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'],
Expand Down
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}
}
Expand Down
10 changes: 6 additions & 4 deletions manifests/log.pp
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions templates/awslogs_log.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>