Thanos, Prometheus, and Grafana were each placed in the same ec2 as containers. At this time, ec2 is in the public subnet, and eks is in the private subnet. I want to use Thanos to store Prometheus' metrics in an AWS S3 bucket, but there seems to be a problem connecting Prometheus and Thanos. In the current situation, even if all containers are running, objects are not being created in the AWS S3 bucket. The error log below is an error in the Prometheus container, and below it is the Docker-Compose file. Could you please let me know what the problem is?
ts=2023-09-xxxxx:42:44.---- caller=dedupe.go:112 component=remote level=warn remote_name=****da url=http://192.xxx.xx.x:xxxxx/api/v1/write msg="Failed to send batch, retrying" err="Post \"http://192.xxx.xx.x:xxxxx/api/v1/write\": write tcp 192.xxx.xx.4:35630->192.xxx.xx.5:xxxxx: write: connection reset by peer"
I tried changing the endpoint and modifying the Docker compose file in various ways, but I couldn't solve it.
The error message
write tcp 192.xxx.xx.4:35630->192.xxx.xx.5:xxxxx: write: connection reset by peerindicates that the Prometheus container is trying to send metrics to the Thanos container on portxxxxx, but the connection is being reset by the peer. This can happen for a few reasons, such as:xxxxx.In your case, it is most likely that the Prometheus and Thanos containers are on different subnets and cannot communicate with each other. This is because you mentioned that the EC2 instance is in the public subnet and the EKS cluster is in the private subnet.
To fix this problem, you need to create a VPC peering connection between the public subnet and the private subnet. This will allow the Prometheus and Thanos containers to communicate with each other.
Once you have created a VPC peering connection, you need to update the Prometheus configuration to point to the Thanos endpoint on the private subnet. You can do this by setting the
remote_write.targetsparameter in the Prometheus configuration file to the Thanos endpoint.For example, if the Thanos endpoint is
http://192.168.1.10:9090, you would set theremote_write.targetsparameter to["http://192.168.1.10:9090"].Once you have updated the Prometheus configuration, you need to restart the Prometheus container.
Here is an example of a Docker Compose file that you could use to run Prometheus and Thanos in different subnets:
To run the Docker Compose file, you can use the following command:
This will start the Prometheus and Thanos containers in different subnets.
Once the Prometheus and Thanos containers are running, you should be able to see objects being created in the AWS S3 bucket.
If you are still having problems, please provide more information about your environment, such as the output of the following commands: