跳至内容

Monitoring traffic from certain IPs

0

What are some ways to alert on excessive amount of data being received by an EC2 instance from certain IPs and on certain ports?

AWS
已提问 9 个月前133 查看次数
1 回答
1
已接受的回答

What are some ways to alert on excessive amount of data being received by an EC2 instance from certain IPs and on certain ports?

Cloudwatch Metrics shows packets and bytes in/out of an EC2, but it does not allow additional filtering based on IP and port. VPC flow logs along with Custom Metrics can be leveraged for this solution. Here are the steps:

  1. Navigate to the CloudWatch Log Group for VPC Flow logs of your VPC > Actions > Create Metric Filter a. For the filter pattern input: [version, account, eni = “ENI-OF-EC2-TO-MONITOR”, source = “SOURCE-IP-TO-MONITOR”, destination, srcport, destport="PORT-TO-MONITOR", protocol, packets, bytes, windowstart, windowend, action="ACCEPT", flowlogstatus] – note that this pattern may be different if you are using additional fields available in later version of Flow Logs. The above is based on the default pattern.
  2. Fill out the filter name, metric namespace.
  3. For Metric Value enter: $bytes. This will publish the amount of bytes for each entry to the CloudWatch metric.
  4. Default value can be set to: 0
  5. Unit set to: bytes
  6. Leave all else default and create metric.

Once this is done you can navigate to Cloudwatch Metrics and see the metric in your namespace. Every time there is a request made to the ENI, from the IP, to the destination port, the bytes of that request will be logged to the metric.

From the Graphed Metrics tab, an Alarm can be setup on the bytes metric. The alarm can be made on something like “when average bytes sent over 5 minutes exceeds 10,000”. This will depend on what you want to alert on and what is a proper baseline. The Alarm can be configured to trigger an SNS topic that will notify appropriate users, or a Lambda function that can take automated action.

AWS
已回答 9 个月前
专家
已审核 9 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。