Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 57b1a8f

Browse files
committedApr 10, 2018
upgrade + 1 single fat container
1 parent 4d1288e commit 57b1a8f

9 files changed

+149
-17
lines changed
 

‎Dockerfile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
#
3+
# 1 single fat container for hosting demo in 1 Clever Cloud instance ;)
4+
#
5+
6+
7+
FROM prom/prometheus:v2.2.1 AS prometheus
8+
9+
10+
# get demo app
11+
FROM samber/node-promfiler-demo
12+
13+
# get prometheus
14+
COPY --from=prometheus /bin/prometheus /bin/prometheus
15+
COPY --from=prometheus /etc/prometheus /etc/prometheus
16+
COPY demo/prometheus.yml /etc/prometheus/prometheus.yml
17+
18+
# get grafana
19+
ARG DOWNLOAD_URL="https://s3-us-west-2.amazonaws.com/grafana-releases/master/grafana_latest_amd64.deb"
20+
RUN apt-get update && \
21+
apt-get -y --no-install-recommends install libfontconfig curl ca-certificates && \
22+
apt-get clean && \
23+
curl ${DOWNLOAD_URL} > /tmp/grafana.deb && \
24+
dpkg -i /tmp/grafana.deb && \
25+
rm /tmp/grafana.deb && \
26+
curl -L https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 > /usr/sbin/gosu && \
27+
chmod +x /usr/sbin/gosu && \
28+
apt-get autoremove -y && \
29+
rm -rf /var/lib/apt/lists/*
30+
COPY demo/grafana.sh /grafana.sh
31+
COPY demo/grafana.db /var/lib/grafana/grafana.db
32+
COPY dist/ /var/lib/grafana/plugins/grafana-flamegraph-panel
33+
34+
# get containerpilot
35+
RUN wget https://github.com/joyent/containerpilot/releases/download/3.7.0/containerpilot-3.7.0.tar.gz \
36+
&& tar xvf containerpilot-3.7.0.tar.gz \
37+
&& rm containerpilot-3.7.0.tar.gz \
38+
&& mv containerpilot /bin/containerpilot
39+
COPY demo/containerpilot.json /etc/containerpilot.json
40+
41+
CMD /bin/containerpilot -config /etc/containerpilot.json

‎README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@ Please read [Brendan Gregg's post](http://www.brendangregg.com/flamegraphs.html)
88

99
## Demo
1010

11-
**[Grafana live demo](https://grafana.flamgraph.samuel-berthe.fr/dashboard/db/demo-flamegraph?orgId=1)**
11+
**[Grafana live demo](https://grafana.flamegraph.samuel-berthe.fr/d/000000001/demo-flamegraph?orgId=1)**
1212

13-
To generate metrics on the "demo" service, execute many times:
14-
15-
```
16-
$ curl https://demo.flamgraph.samuel-berthe.fr
17-
```
13+
To generate metrics on the "demo" service (docker samber/node-promfiler-demo), a cronjob executes requests on API regulary.
1814

1915
You will see some `pow()` calls in the graph.
2016

21-
Metrics are collected every 30 secondes, plz keep waiting if `pow()` is not shown on the flame graph.
22-
2317
## Live profiling
2418

2519
### Prometheus + NodeJS

‎demo/Caddyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
https://grafana.flamgraph.samuel-berthe.fr {
2+
https://grafana.flamegraph.samuel-berthe.fr {
33

44
tls dev@samuel-berthe.fr
55
proxy / localhost:3000

‎demo/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Dashboard: demo-flamgraph
1818
## Producing stack traces
1919

2020
```
21-
$ curl localhost:8080
22-
$ curl localhost:8080
23-
$ curl localhost:8080
24-
$ curl localhost:8080
25-
$ curl localhost:8080
21+
$ curl localhost:8000
22+
$ curl localhost:8000
23+
$ curl localhost:8000
24+
$ curl localhost:8000
25+
$ curl localhost:8000
2626
...
2727
```

‎demo/containerpilot.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
consul: "1.2.3.4:8500",
3+
logging: {
4+
level: "INFO",
5+
format: "default",
6+
output: "stdout"
7+
},
8+
jobs: [
9+
{
10+
name: "grafana",
11+
exec: "/grafana.sh",
12+
restarts: "unlimited"
13+
},
14+
{
15+
name: "prometheus",
16+
exec: "/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus --storage.tsdb.retention=1h",
17+
restarts: "unlimited"
18+
},
19+
{
20+
name: "node-promfiler-demo",
21+
exec: "node-promfiler --sampling-interval=100 /app/app.js",
22+
restarts: "999999999",
23+
port: 8080,
24+
when: {
25+
source: "schedule-restart",
26+
each: "exitSuccess"
27+
},
28+
health: {
29+
exec: "/usr/bin/curl localhost:8000",
30+
interval: 42,
31+
ttl: 42,
32+
timeout: "5s",
33+
},
34+
},
35+
{
36+
name: "schedule-restart",
37+
exec: "echo 0",
38+
restarts: "unlimited",
39+
when: {
40+
interval: 900,
41+
}
42+
}
43+
]
44+
}

‎demo/docker-compose.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ services:
2929
restart: unless-stopped
3030

3131
exporter:
32-
image: samber/node-promfile-demo
32+
image: samber/node-promfiler-demo
3333
ports:
34-
- 127.0.0.1:8080:8080
34+
- 127.0.0.1:8000:8000
3535
expose:
3636
- 9142
37+
environment:
38+
- PORT=8000
3739
restart: unless-stopped
3840

3941
volumes:

‎demo/grafana.db

45 KB
Binary file not shown.

‎demo/grafana.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash -e
2+
3+
: "${GF_PATHS_CONFIG:=/etc/grafana/grafana.ini}"
4+
: "${GF_PATHS_DATA:=/var/lib/grafana}"
5+
: "${GF_PATHS_LOGS:=/var/log/grafana}"
6+
: "${GF_PATHS_PLUGINS:=/var/lib/grafana/plugins}"
7+
: "${GF_PATHS_PROVISIONING:=/etc/grafana/provisioning}"
8+
9+
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_LOGS" || true
10+
11+
if [ ! -z ${GF_AWS_PROFILES+x} ]; then
12+
mkdir -p ~grafana/.aws/
13+
> ~grafana/.aws/credentials
14+
15+
for profile in ${GF_AWS_PROFILES}; do
16+
access_key_varname="GF_AWS_${profile}_ACCESS_KEY_ID"
17+
secret_key_varname="GF_AWS_${profile}_SECRET_ACCESS_KEY"
18+
region_varname="GF_AWS_${profile}_REGION"
19+
20+
if [ ! -z "${!access_key_varname}" -a ! -z "${!secret_key_varname}" ]; then
21+
echo "[${profile}]" >> ~grafana/.aws/credentials
22+
echo "aws_access_key_id = ${!access_key_varname}" >> ~grafana/.aws/credentials
23+
echo "aws_secret_access_key = ${!secret_key_varname}" >> ~grafana/.aws/credentials
24+
if [ ! -z "${!region_varname}" ]; then
25+
echo "region = ${!region_varname}" >> ~grafana/.aws/credentials
26+
fi
27+
fi
28+
done
29+
30+
chown grafana:grafana -R ~grafana/.aws
31+
chmod 600 ~grafana/.aws/credentials
32+
fi
33+
34+
if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then
35+
OLDIFS=$IFS
36+
IFS=','
37+
for plugin in ${GF_INSTALL_PLUGINS}; do
38+
IFS=$OLDIFS
39+
gosu grafana grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}
40+
done
41+
fi
42+
43+
exec gosu grafana /usr/sbin/grafana-server \
44+
--homepath=/usr/share/grafana \
45+
--config="$GF_PATHS_CONFIG" \
46+
"$@" \
47+
cfg:default.log.mode="console" \
48+
cfg:default.paths.data="$GF_PATHS_DATA" \
49+
cfg:default.paths.logs="$GF_PATHS_LOGS" \
50+
cfg:default.paths.plugins="$GF_PATHS_PLUGINS" \
51+
cfg:default.paths.provisioning=$GF_PATHS_PROVISIONING

‎demo/prometheus.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ scrape_configs:
77
scrape_interval: 30s
88
scrape_timeout: 3s
99
static_configs:
10-
- targets: ['exporter:9142']
10+
- targets: ['localhost:9142']

0 commit comments

Comments
 (0)
This repository has been archived.