Docker Compose For Prometheus + Grafana

Test your Prometheus and Grafana Integration Locally for any service you are writing for your next project. Simply point the app to send the metrics to the local instance and test the metrics quickly


Neenad Ingole

5 days ago | 2 min read

It becomes important that with all the tools you have in production, you can test the user flows end to end locally with very fewer efforts. The rationale behind such is the reduced feedback cycle that saves a developer from taking a long time to achieve the desired outcome.

I was working on sending some telemetry data from my Golang web application to Prometheus and then creating a Grafana dashboard out of it. But to test the flow I needed a local setup of Prometheus + Grafana so that I can check if the metrics are right and that I am building the right PromQL query to create the dashboard.

I am maintaining a Github repo for all the docker-compose setups I require for my local testing and now Prometheus + Grafana is a new addition to it. If you also need a similar setup and save your setup time in future and focus more on building things refer to this post or my Github Repository.

Clone the repo: Docker-images

Then go to prometheus-grafana folder and run docker-compose up -d.

This will start Prometheus on http://localhost:9090 and Grafana on http://localhost:3000.

Prometheus Alert Manager

There is also a prometheus.yml the configuration file which you can use to add the local apps that you want to scrape, a note: if your application is running inside a docker then use host.docker.internal as your hostname with the port to scrape the target.


scrape_interval: 15s

evaluation_interval: 15s


# - "first.rules"

# - "second.rules"


- job_name: prometheus


- targets: ['localhost:9090']

- job_name: app

scrape_interval: 5s


- targets: ['host.docker.internal:10088']

Grafana settings to connect to local Prometheus

Once you have added the configs to connect Grafana to Prometheus like the above image, you are ready with an end-to-end setup on your local.

If you also have your own docker-compose stack setups that you use during your development please don't hesitate to share with me by sending me a PR to the repository.

I hope you will find this docker-compose configuration pretty useful and saves you time. Please subscribe to the newsletter to get more articles delivered right to your inbox.

Thanks and Happy Coding!



Created by

Neenad Ingole

Senior Golang Engineer

I am a FullStack developer who is currently focusing more on Backend services using Golang for large scale enterprises. Consulting, OS contribution, blogging and sharing solutions to day to day tech challenges. If you are looking to solve some challenging problem give me a nudge.







Related Articles