Prometheus doesn't care what IP address it listens on, and as far as I know nor does Grafana. If they are running in the same VM, and Grafana is pointing to
http://127.0.0.1:9090 to query Prometheus, then it won't even notice the change.
The things which will will make a difference are:
- if you change the IP addresses of the targets that are being scraped
- if the targets are using firewall rules or ACLs to accept scrapes only from a particular IP address
- if the targets are configured to use Remote Write to connect actively to the Prometheus server on its IP address (this is a relatively unusual configuration)
- if anything else connects to Prometheus to query it