Monitor EC2 Host Based Intrusion Detection Alerts with OSSEC, CloudWatch Logs, Lambda and Elasticsearch
This solution uses Amazon CloudWatch Logs to collect and aggregate alerts in near real time from an open-source security (OSSEC) HIDS. It uses a CloudWatch Logs Subscription to deliver the alerts to Amazon Elasticsearch Service (Amazon ES) for analysis and visualization with Kibana.
This solution contains a test environment AWS CloudFormation stack that you can automatically provision into an existing Amazon VPC subnet. The CloudFormation template performs the following high-level steps in the region you choose:
- Creates two EC2 instances running Amazon Linux with an AWS Identity and Access Management (IAM) role for CloudWatch Logs access. Note: In order to provide sample HIDS alert data, the two EC2 instances are configured automatically to generate simulated HIDS alerts locally.
- Installs and configures OSSEC, the CloudWatch Logs agent, and additional packages used for the test environment.
- Creates the target HIDS Amazon ES domain.
- Creates the target HIDS CloudWatch Logs group.
- Creates the Lambda function and CloudWatch Logs Subscription in order to send HIDS alerts to Amazon ES.
Note that this solution depends on Amazon ES and Lambda that, at the time of this writing, are available in the following regions: US East (N. Virginia), US East (Ohio), US West (Oregon), US West (N. California), EU (Ireland), EU (Frankfurt), Asia Pacific (Singapore), Asia Pacific (Tokyo), Asia Pacific (Sydney), and Asia Pacific (Seoul).
If you already have a VPC Subnet configured with internet access, you can launch the stack:
- On the target EC2 instances, the OSSEC HIDS generates alerts that the CloudWatch Logs agent captures. The HIDS performs log analysis, integrity checking, Windows registry monitoring, rootkit detection, realtime alerting, and active response. For more information, see Getting started with OSSEC.
- The CloudWatch Logs group receives the alerts as events.
- A CloudWatch Logs subscription is applied to the target log group to forward the events through AWS Lambda to Amazon ES.
- Amazon ES loads the logged alert data.
- Kibana visualizes the alerts in near real time. Kibana is a popular open-source visualization tool designed to work with Amazon ES, which provides a default installation of Kibana with every Amazon ES domain.
Thanks to the OSSEC Project Team for authoring the OSSEC HIDS.