How to collect logs using AWS ECS + Grafana + Loki

There is an AWS ECS cluster consisting of two instances.
There are several spring boot services in the cluster, but they are composed of two instances, so two identical services are running.

The load balancer distributes traffic evenly.

In this state, I created a separate log collection EC2 for log centralization, and I built it through Grafana and Loki in log collection EC2.

Now I want to send logs to the Loki of log collection EC2 in the cluster.

However, one thing to note at this time is that whenever ECS containers are distributed, they are randomly renamed to Service Name + Metadata, and as I said above, the same service is running on different instances, and I want to label them and see them as one log.

What I want is to see the log at once, for example, regardless of instance 1 or instance 2 for server A. Even after server A is newly built and deployed, it’s the same.

How can I set it up?