Docker Machine + Ngninx + Prometheus + Grafana to provision on a single host
Maybe you don't need a self-managed kubernetes with 3rd party monitoring solutions, maybe a single docker instance running is enough to hold many of your pet projects
-
Create an account somewhere where you can spin up cheap instances (like on scaleway or digitalocean)
-
Install docker machine if you don't already have it (try docker-machine in your bash)
-
Provision docker machine on the instance following this guide:
-
Point your docker to the recently provisioned machine
eval $(docker-machine env your-machine-name)
-
Clone this repo and put everything up
docker-compose build docker-compose up -d
Now you can go to any other of your projects which have a docker file and simply run them on this machine as well, you can follow the example under example-app
cd example-app
docker-compose build
docker-compose up -d
If everything worked, go to your server ip address and you should see this:
The way it works is by having all containers sharing the same host network, which means that you need to make them run on different ports to not conflict, then you can change nginx/nginx.conf to route traffic corretly to multiple apps according to the domain
Go to http://yourserver/metrics you should see metrics for our example-app, including one named user_clicks. You can see the code used to generate it on example-app/index.js
Now go to http://yourserver:9090, you will see the Prometheus dashboard, there you can query the metrics, you can add more apps in prometheus/prometheus.yml
For building dashboards, you can go to grafana, on http://yourserver:3000, sing in with admin/admin, set up a new password, choose prometheus as data source with default options and localhost:9090, and get started.
You can create a dashboard with the metric user_clicks
or process_resident_memory_bytes
for example
For error tracking there are actually good SaaS with free plans available for small projects on sentry.io or rollbar.com
You should probably block the ports other then 80 or 443 in your host, and add a password to prometheus