Skip to content

Commit 4f645da

Browse files
committed
feat(init): initial commit
0 parents  commit 4f645da

16 files changed

Lines changed: 307 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*~
2+
*.swp
3+
*.swo

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Deis Monitor
2+
3+
This project aims to provide a Prometheus based component, designed to make basic cluster monitoring simple and straight forward.
4+
5+
The Monitor component is under development, and not recommended for production use at this time.

v1/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Deis V1 monitoring
2+
3+
This system aims to provides a base level of monitoring and telemetry for Deis 1.x installations. It is an optional
4+
component that, once started, can give some insight into the state and health of the system.
5+
6+
This system is under heavy development and is not recommended for production use at this time.

v1/alertmanager/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM prom/alertmanager:0.0.4
2+
3+
USER root
4+
5+
WORKDIR /tmp
6+
7+
RUN apk add --update-cache curl bash sudo && rm -rf /var/cache/apk/*
8+
9+
RUN curl -L https://github.com/coreos/etcd/releases/download/v2.2.1/etcd-v2.2.1-linux-amd64.tar.gz -o /tmp/etcd-v2.2.1-linux-amd64.tar.gz
10+
11+
RUN tar xzvf /tmp/etcd-v2.2.1-linux-amd64.tar.gz
12+
13+
RUN cp /tmp/etcd-v2.2.1-linux-amd64/etcdctl /usr/local/bin/etcdctl && chmod +x /usr/local/bin/etcdctl
14+
15+
# install confd
16+
RUN curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.10.0/confd-0.10.0-linux-amd64 \
17+
&& chmod +x /usr/local/bin/confd
18+
19+
COPY rootfs /
20+
21+
EXPOSE 9093
22+
23+
ENTRYPOINT [ "/bin/boot.sh" ]
24+
25+
ENV DEIS_RELEASE 1.12.0-dev

v1/alertmanager/rootfs/bin/boot.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
[[ $DEBUG ]] && set -x
6+
7+
# configure etcd
8+
export ETCD_PORT="${ETCD_PORT:-4001}"
9+
export ETCD="$HOST:$ETCD_PORT"
10+
export ETCD_PATH="${ETCD_PATH:-/deis/monitor}"
11+
export ETCD_TTL="${ETCD_TTL:-20}"
12+
13+
14+
until etcdctl --no-sync -C "$ETCD" ls >/dev/null 2>&1; do
15+
echo "alertmanager: waiting for etcd at ${ETCD}..."
16+
sleep $((ETCD_TTL/2)) # sleep for half the TTL
17+
done
18+
19+
until confd -onetime -node "$ETCD" --confdir /etc/confd --log-level error; do
20+
echo "alertmanager: waiting for confd to write initial templates..."
21+
sleep $((ETCD_TTL/2)) # sleep for half the TTL
22+
done
23+
24+
confd -node "$ETCD" --confdir /etc/confd --log-level info --interval 5 &
25+
26+
echo "alertmanager: starting alertmanager"
27+
/bin/alertmanager -config.file=/etc/alertmanager/alertmanager.yml $OPTS &
28+
SERVICE_PID=$!
29+
echo $SERVICE_PID > /var/spool/alertmanager.pid
30+
echo "alertmanager: alertmanager has been started in background with pid: ${SERVICE_PID}"
31+
32+
wait
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[template]
2+
src = "alertmanager.yml"
3+
dest = "/etc/alertmanager/alertmanager.yml"
4+
uid = 0
5+
gid = 0
6+
mode = "0644"
7+
keys = [
8+
"/deis/monitor",
9+
]
10+
reload_cmd = "kill -HUP `cat /var/spool/alertmanager.pid`" # does this even work?
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# expand to all the things
2+
{{ if exists "/deis/monitor/slack_webhook_url" }}
3+
notification_config {
4+
name: "alertmanager_slack"
5+
slack_config {
6+
webhook_url: "{{ getv "/deis/monitor/slack_webhook_url" }}"
7+
channel: "#{{ getv "/deis/monitor/slack_webhook_channel" }}"
8+
send_resolved: true
9+
}
10+
}
11+
12+
aggregation_rule {
13+
repeat_rate_seconds: 3600
14+
notification_config_name: "alertmanager_slack"
15+
}
16+
{{ end }}

v1/daemon/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM prom/prometheus:0.16.1
2+
3+
WORKDIR /tmp
4+
5+
RUN apk add --update-cache curl bash sudo && rm -rf /var/cache/apk/*
6+
7+
RUN curl -L https://github.com/coreos/etcd/releases/download/v2.2.1/etcd-v2.2.1-linux-amd64.tar.gz -o /tmp/etcd-v2.2.1-linux-amd64.tar.gz
8+
9+
RUN tar xzvf /tmp/etcd-v2.2.1-linux-amd64.tar.gz
10+
11+
RUN cp /tmp/etcd-v2.2.1-linux-amd64/etcdctl /usr/local/bin/etcdctl && chmod +x /usr/local/bin/etcdctl
12+
13+
# install confd
14+
RUN curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.10.0/confd-0.10.0-linux-amd64 \
15+
&& chmod +x /usr/local/bin/confd
16+
17+
COPY rootfs /
18+
19+
ENTRYPOINT [ "/bin/boot.sh" ]
20+
21+
ENV DEIS_RELEASE 1.12.0-dev

v1/daemon/rootfs/bin/boot.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
[[ $DEBUG ]] && set -x
6+
7+
# configure etcd
8+
export ETCD_PORT="${ETCD_PORT:-4001}"
9+
export ETCD="$HOST:$ETCD_PORT"
10+
export ETCD_PATH="${ETCD_PATH:-/deis/monitor}"
11+
export ETCD_TTL="${ETCD_TTL:-20}"
12+
13+
until etcdctl --no-sync -C "$ETCD" ls >/dev/null 2>&1; do
14+
echo "monitor: waiting for etcd at ${ETCD}..."
15+
sleep $((ETCD_TTL/2)) # sleep for half the TTL
16+
done
17+
18+
until confd -onetime -node "$ETCD" --confdir /etc/confd --log-level error; do
19+
echo "monitor: waiting for confd to write initial templates..."
20+
sleep $((ETCD_TTL/2)) # sleep for half the TTL
21+
done
22+
23+
set +e
24+
25+
OPTS=""
26+
27+
if ALERT_MANAGER="$(etcdctl -C "$ETCD" get /deis/monitor/alertManagerUri)"; then
28+
OPTS="-alertmanager.url=$ALERT_MANAGER"
29+
fi
30+
31+
set -e
32+
33+
confd -node "$ETCD" --confdir /etc/confd --log-level info --interval 5 &
34+
35+
echo "monitor: starting prometheus"
36+
/bin/prometheus -config.file=/etc/prometheus/prometheus.yml $OPTS &
37+
SERVICE_PID=$!
38+
echo $SERVICE_PID > /var/spool/prometheus.pid
39+
echo "monitor: monitor has been started in background with pid: ${SERVICE_PID}"
40+
41+
# @fixme: hax. how else can we accomplish this?.
42+
echo "monitor: updating etcd node list in... etcd"
43+
while true; do
44+
for uri in $(etcdctl -C "$ETCD" member list | awk '{print $4}' | awk -F= '{print $2}' | awk -F, '{print $1}'); do
45+
host=$(echo $uri | awk -F: '{print $2}')
46+
port=$(echo $uri | awk -F: '{print $3}')
47+
if ! etcdctl -C "$ETCD" get /deis/monitor/endpoints/etcd/$host >/dev/null 2>&1; then
48+
etcdctl -C "$ETCD" set /deis/monitor/endpoints/etcd/$host $port >/dev/null 2>&1;
49+
fi
50+
done
51+
sleep 60
52+
done
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# on cadvisor container start, set a key under monitored hosts.
2+
[template]
3+
src = "prometheus.yml"
4+
dest = "/etc/prometheus/prometheus.yml"
5+
uid = 0
6+
gid = 0
7+
mode = "0644"
8+
keys = [
9+
"/deis/monitor",
10+
]
11+
reload_cmd = "kill -HUP `cat /var/spool/prometheus.pid`" # @fixme: fine for demo, improve later

0 commit comments

Comments
 (0)