Ultimately I’ll be standing up a Prometheus / Grafana inside a single AWS Fargate instance. I’m working on it inside a Docker instance on my desktop. I found something weird I’m trying to understand.
I configured my datasource like this:
apiVersion: 1 datasources: - name: Prometheus type: prometheus access: direct orgId: 1 url: http://localhost:9090 isDefault: true
And I start the instance with:
docker run -d \ --name prometheus \ --hostname prometheus \ -p 8110:22 \ # -p 9090:9090 \ -p 9091:9091 \ prometheus:latest
I have prometheus on 9090 and grafana on 9091. I wasn’t originally doing the -p 9090:9090, and Grafana was reporting No metrics. I decided to break the problem into two and tried to attach to Prometheus’s built in graphing, which is when I added the port map for Prometheus, and suddenly Grafana reports data.
So I’m confused. Does the URL used for the datasource need to be externally resolvable? Is it actually being hit by my own browser or something along those lines? When I configure this for my AWS instance, do I need to make Prometheus accessible and use a datasource URL that will resolve?
Can someone explain why port-mapping the Prometheus port suddenly exposed my data?
(I suspect if I knew how Grafana worked under the hood, the answer would be obvious. I think I’ll go digging for that.)