How to config Prometheus to scrape all IPs behind a hostname in single period?

The configuration in the question appears correct for the task. However, in order to make it work, the DNS response must contain all target IPs at once. The way it works is like this:

  1. Prometheus makes a DNS request to obtain a list of targets.
  2. The list of targets gets cached for refresh_interval: 2s.
  3. Prometheus makes a scrape request for each target in the list.

At next iterations (defined by the scrape_interval) Prometheus may skip p.1 and p.2 if the the list of targets is not yet expired. The problem in the question is that DNS server returned only one IP and thus, Prometheus at each scrape_interval made only one scrape request. The randomly selected target received it's unique IP-based instance label and this is why the graph looks disconnected.