Connection between EC2 instance and RDS

1

We have the database of 3 websites on a single RDS mySQL instance, and sometimes 1 website gets disconnected from the database and goes down without affecting other websites. We came to the conclusion that the disconnection could be due to one the 2 cases below:-

  1. Something is going wrong in the connection the Database and EC2 instance on which the website is hosted.
  2. There may be a connection pool issue on the application end as we manually set up the connection pool in the code of the website as we use Jave.

To figure out the root cause of the disconnection if any as per point 1), we activated VPC flow logs, but are unable to figure out how to filter the logs such that we can know what goes on when the disconnection happens. The custom log format we have set is below:

${instance-id} ${srcaddr} ${srcport} ${pkt-srcaddr} ${pkt-src-aws-service} ${dstaddr} ${dstport} ${pkt-dstaddr} ${pkt-dst-aws-service} ${flow-direction} ${traffic-path} ${action} ${log-status}

How do we filter the logs based on traffic flowing from the suspected EC2 instance and the RDS so we can figure out what is happening and what is the cause for the disconnection?

  • Have you been able to resolve your issue? If so, would you select an answer that matched your issue to close out the thread?

2 Answers
0
Accepted Answer

You can use the following filter pattern in CloudWatch Logs to search (all logs streams) for either of the two IP addresses in the log group, for example:

  • 10.1.1.1 - server 1
  • 10.2.2.2 - server 2

like this:

%10\.1\.1\.1|10\.2\.2\.2%

Simply update this with your server IPs.

See more syntax rules here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html#matching-terms-events

AWS
LondonX
answered 7 months ago
0

Hi,

To analyse VPC flow logs, you can use Athena and do simple SQL queries against them. Please follow the documentation https://docs.aws.amazon.com/athena/latest/ug/vpc-flow-logs.html

profile picture
EXPERT
answered 7 months ago
profile pictureAWS
EXPERT
reviewed 7 months ago
  • Thank you very much for your reply. Our flow logs are sent to cloudwatch logs and according to the document, flow logs must be sent to S3. Is there any way to filter logs which show details of the connection between our RDS and EC2?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions