Skip to content

Instantly share code, notes, and snippets.

@crccheck
Last active August 29, 2015 14:19
Show Gist options
  • Save crccheck/f2ed20276c19d0f31825 to your computer and use it in GitHub Desktop.
Save crccheck/f2ed20276c19d0f31825 to your computer and use it in GitHub Desktop.
Prometheus+Docker bootstrap
#### PROMETHEUS ##################################
.PHONY: prom
# add-host hack:
# https://github.com/docker/docker/issues/1143#issuecomment-70052272
prom: prom_exp prom_node
-@docker rm -f $@_1 > /dev/null
docker run -d --name $@_1 \
-v ${PWD}/prom/prometheus.conf:/prometheus.conf:ro \
-v ${PWD}/prom/data:/prometheus \
--link prom_exp_1:prom_exp_1 \
--add-host=dockerhost:$$(ip route | awk '/docker0/ { print $$NF }') \
-p 9090:9090 \
prom/prometheus
prom_exp:
-@docker rm -f $@_1 > /dev/null
docker run -d --name $@_1 \
-v /sys/fs/cgroup:/cgroup:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
prom/container-exporter
# use net=host to expose metrics about host interfaces
prom_node:
-@docker rm -f $@_1 > /dev/null
docker run -d --name $@_1 \
--net=host \
prom/node-exporter
prom/dashboard/dashboard.sqlite3:
docker run \
-e DATABASE_URL=sqlite3:/data/dashboard.sqlite3 \
-v ${PWD}/prom/dashboard:/data:rw \
crccheck/promdash ./bin/rake db:setup
# dashboard
promdash: prom/dashboard/dashboard.sqlite3 prom
-@docker rm -f $@_1 > /dev/null
docker run -d --name $@_1 \
-e DATABASE_URL=sqlite3:/data/dashboard.sqlite3 \
-v ${PWD}/prom/dashboard:/data:rw \
crccheck/promdash
global {
scrape_interval: "30s" # By default, scrape targets every 15 seconds.
}
job: {
name: "container-exporter"
target_group: {
target: "http://prom_exp_1:9104/metrics"
}
}
job: {
name: "node-exporter"
target_group: {
target: "http://dockerhost:9100/metrics"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment