Prometheus Development Environment
Why?
Recently I needed a test environment to support development of a new metrics endpoint for a service I was developing. To support this effort I decided to use the Prometheus project by Brian Christner. This project is a complete docker compose based development stack for Prometheus and Grafana.
Prerequisites
Before following these steps you’ll need to ensure your machine has docker and docker swarm installed. I’m performing this development on a Mac and the default docker install includes docker swarm. If you have never used docker swarm on your docker install before you will need to run this command.
docker swarm init
You should see some output saying “Swarm initialized”.
Running vegasbrianc/prometheus
In order to run vegasbrianc/prometheus first you’ll need to clone the git repo to your machine.
git clone https://github.com/vegasbrianc/prometheus.git
Next change into the newly created prometheus directory and deploy the stack.
cd prometheus
HOSTNAME=$(hostname) docker stack deploy -c docker-stack.yml prom
The output should look like this.
Creating network prom_monitor-net
Creating service prom_prometheus
Creating service prom_node-exporter
Creating service prom_alertmanager
Creating service prom_cadvisor
Creating service prom_grafana
Running docker service ls will list the ports that each service is listening on.
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
zarsfv67tb3v prom_alertmanager replicated 1/1 prom/alertmanager:latest *:9093->9093/tcp
ag0uubtdvedb prom_cadvisor global 1/1 google/cadvisor:latest *:8080->8080/tcp
yujqjdoqbhjg prom_grafana replicated 1/1 grafana/grafana:latest *:3000->3000/tcp
x49d9pzpv477 prom_node-exporter global 1/1 prom/node-exporter:latest *:9100->9100/tcp
a2l7fr6rx8u4 prom_prometheus replicated 1/1 prom/prometheus:latest *:9090->9090/tcp
What’s next?
If the above steps completed successfully you should now have a copy of Prometheus and it’s ancillary services running on your machine. Be aware this is not a production ready installation, there is essentially no security. Brian provides security recommendations in the project’s README. I hope to add some additional articles about deploying Prometheus in production using Ansible as well as development of metrics endpoints in Golang. Stay tuned for updates!
Comments