Skip to content

Commit 8bc3d5c

Browse files
authored
Remote rendering: Collect and expose Prometheus metrics (#71)
Support enable Prometheus metrics endpoint, exposing Node.js and render request latency (histogram) metrics. Adds HA-setup and load test to ease load testing current solution, but also prepares for comparing implementation of #66. Closes #69
1 parent e35d402 commit 8bc3d5c

File tree

20 files changed

+7906
-5
lines changed

20 files changed

+7906
-5
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
.circleci
2+
.github
23
artifacts
34
build
5+
devenv
46
dist
5-
docker
67
docs
78
node_modules
89
scripts
10+
.prettierignore
11+
.prettierrc.json
912
Dockerfile
1013
Makefile
1114
plugin_start*
15+
tslint.json

devenv/docker/ha/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Grafana Image Rendering High Availability (HA) test setup
2+
3+
A set of docker compose services which together creates a Grafana Image Rendering HA test setup with capability of easily
4+
scaling up/down number of Grafana image renderer instances.
5+
6+
Included services
7+
8+
* Grafana
9+
* Grafana image renderer service
10+
* Mysql - Grafana configuration database
11+
* Prometheus - Monitoring of Grafana and used as data source of provisioned alert rules
12+
* cAdvisor - Docker monitoring
13+
* Nginx - Reverse proxy for Grafana, Grafana image renderer and Prometheus. Enables browsing Grafana/renderer/Prometheus UI using a hostname
14+
15+
## Prerequisites
16+
17+
### Build grafana image renderer docker container
18+
19+
Build a Grafana image renderer docker container and tag it as grafana/grafana-image-renderer:dev.
20+
21+
```bash
22+
$ cd <grafana-image-renderer repo>
23+
$ docker build -t grafana/grafana-image-renderer:dev .
24+
```
25+
26+
### Virtual host names
27+
28+
#### Alternative 1 - Use dnsmasq
29+
30+
```bash
31+
$ sudo apt-get install dnsmasq
32+
$ echo 'address=/loc/127.0.0.1' | sudo tee /etc/dnsmasq.d/dnsmasq-loc.conf > /dev/null
33+
$ sudo /etc/init.d/dnsmasq restart
34+
$ ping whatever.loc
35+
PING whatever.loc (127.0.0.1) 56(84) bytes of data.
36+
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.076 ms
37+
--- whatever.loc ping statistics ---
38+
1 packet transmitted, 1 received, 0% packet loss, time 1998ms
39+
```
40+
41+
#### Alternative 2 - Manually update /etc/hosts
42+
43+
Update your `/etc/hosts` to be able to access Grafana and/or Prometheus UI using a hostname.
44+
45+
```bash
46+
$ cat /etc/hosts
47+
127.0.0.1 grafana.loc
48+
127.0.0.1 renderer.loc
49+
127.0.0.1 prometheus.loc
50+
```
51+
52+
## Start services
53+
54+
```bash
55+
$ cd <grafana-image-renderer repo>/devenv/docker/ha
56+
$ docker-compose up -d
57+
```
58+
59+
Browse
60+
* http://grafana.loc/
61+
* http://renderer.loc/
62+
* http://prometheus.loc/
63+
64+
Check for any errors
65+
66+
```bash
67+
$ docker-compose logs | grep error
68+
```
69+
70+
You can also provide environment variables for Grafana and Grafana image renderer docker image versions
71+
72+
```bash
73+
$ GRAFANA_VERSION=6.5.0 RENDERER_VERSION=1.0.7 docker-compose up -d
74+
```
75+
76+
### Scale Grafana instances up/down
77+
78+
Scale number of Grafana image renderer instances to `<instances>`
79+
80+
```bash
81+
$ docker-compose up --scale renderer=<instances> -d
82+
# for example 3 instances
83+
$ docker-compose up --scale renderer=3 -d
84+
```
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
version: "2.1"
2+
3+
services:
4+
nginx-proxy:
5+
image: jwilder/nginx-proxy
6+
ports:
7+
- "80:80"
8+
volumes:
9+
- /var/run/docker.sock:/tmp/docker.sock:ro
10+
depends_on:
11+
db:
12+
condition: service_healthy
13+
14+
db:
15+
image: mysql:5.6
16+
environment:
17+
MYSQL_ROOT_PASSWORD: rootpass
18+
MYSQL_DATABASE: grafana
19+
MYSQL_USER: grafana
20+
MYSQL_PASSWORD: password
21+
command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb_monitor_enable=all, --max-connections=1001]
22+
ports:
23+
- 3306
24+
healthcheck:
25+
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
26+
timeout: 10s
27+
retries: 10
28+
29+
mysqld-exporter:
30+
image: prom/mysqld-exporter
31+
environment:
32+
- DATA_SOURCE_NAME=root:rootpass@(db:3306)/
33+
ports:
34+
- 9104
35+
depends_on:
36+
db:
37+
condition: service_healthy
38+
39+
grafana:
40+
image: grafana/grafana:${GRAFANA_VERSION}-ubuntu
41+
volumes:
42+
- ./grafana/provisioning/:/etc/grafana/provisioning/
43+
environment:
44+
- VIRTUAL_HOST=grafana.loc
45+
- GF_SERVER_ROOT_URL=http://grafana.loc
46+
- GF_DATABASE_NAME=grafana
47+
- GF_DATABASE_USER=grafana
48+
- GF_DATABASE_PASSWORD=password
49+
- GF_DATABASE_TYPE=mysql
50+
- GF_DATABASE_HOST=db:3306
51+
- GF_DATABASE_MAX_OPEN_CONN=300
52+
- GF_SERVER_ROUTER_LOGGING=true
53+
- GF_LOG_CONSOLE_FORMAT=json
54+
- GF_LOG_FILTERS=rendering:debug
55+
- GF_RENDERING_SERVER_URL=http://renderer:8081/render
56+
- GF_RENDERING_CALLBACK_URL=http://grafana:3000
57+
ports:
58+
- 3000
59+
links:
60+
- nginx-proxy
61+
depends_on:
62+
db:
63+
condition: service_healthy
64+
65+
renderer:
66+
image: grafana/grafana-image-renderer:${RENDERER_VERSION}
67+
environment:
68+
- VIRTUAL_HOST=renderer.loc
69+
- ENABLE_METRICS=true
70+
ports:
71+
- 8081
72+
mem_limit: 500mb
73+
memswap_limit: 1gb
74+
75+
prometheus:
76+
image: prom/prometheus:v2.14.0
77+
volumes:
78+
- ./prometheus/:/etc/prometheus/
79+
environment:
80+
- VIRTUAL_HOST=prometheus.loc
81+
ports:
82+
- 9090
83+
84+
cadvisor:
85+
image: google/cadvisor:latest
86+
environment:
87+
- VIRTUAL_HOST=cadvisor.loc
88+
ports:
89+
- 8080
90+
volumes:
91+
- /:/rootfs:ro
92+
- /var/run:/var/run:ro
93+
- /sys:/sys:ro
94+
- /var/lib/docker/:/var/lib/docker:ro
95+
- /dev/disk:/dev/disk/:ro
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: 1
2+
3+
providers:
4+
- name: 'General'
5+
type: file
6+
options:
7+
path: /etc/grafana/provisioning/dashboards/general

0 commit comments

Comments
 (0)