jobscore.cloudwatch-logs

CloudWatch Log

CI

This role sets up the CloudWatch Logs agent on an Ubuntu machine.

Requirements

Make sure your AWS credentials are already set up on the machine. You can use either IAM roles or IAM user credentials from the AWS CLI configuration. For more details, check this link: AWS CLI Configuration.

Role Variables

cw_server_type: <ec2 | onPremise>

This variable indicates whether the agent is being installed on an EC2 instance or a local server. The default option is ec2.

aws_region: us-east-1

This variable specifies the AWS region to use if it’s not an EC2 instance.

cw_logs_files: []

This is the key variable, defining the log configurations that you want to manage. It should be a list of logs that the agent will monitor, following this format:

cw_logs_files:
  - log_group_name: /var/log/syslog
    log_stream_name: '{hostname}-{instance_id}'
    timestamp_format: '%b %d %H:%M:%S'
    file_path: /var/log/syslog
    encoding: utf-8
  - log_group_name: /var/log/auth.log
    log_stream_name: '{hostname}-{instance_id}'
    timestamp_format: '%b %d %H:%M:%S'
    file_path: /var/log/auth.log
    encoding: utf-8

In this, log_group_name is the name for the log entry, which should be unique, and the details of the log configuration should follow AWS documentation: CloudWatch Agent Reference.

Dependencies

None

Example Playbook

- hosts: all
  roles:
    - role: jobscore.cloudwatch-logs
      cw_server_type: onPremise
      aws_region: us-east-1
      cw_logs_files:
        - log_group_name: /var/log/syslog
          log_stream_name: '{hostname}-{instance_id}'
          timestamp_format: '%b %d %H:%M:%S'
          file_path: /var/log/syslog
          encoding: utf-8
        - log_group_name: /var/log/auth.log
          log_stream_name: '{hostname}-{instance_id}'
          timestamp_format: '%b %d %H:%M:%S'
          file_path: /var/log/auth.log
          encoding: utf-8

License

GPLv3

Author Information

This role was created by Eric Magalhães and Glauber Batista while working at JobScore Inc.

Informazioni sul progetto

Ansible role for sending logs to CloudWatch

Installa
ansible-galaxy install jobscore.cloudwatch-logs
Licenza
gpl-3.0
Download
24.7k
Proprietario