Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[infra] Import Grafana conf

Manav Rathi2d1e6312af7d
diff --git a/infra/services/grafana/README.md b/infra/services/grafana/README.md
new file mode 100644
index 0000000000..5c9ef8ef96
--- /dev/null
+++ b/infra/services/grafana/README.md
@@ -0,0 +1,37 @@
+# Grafana
+
+Grafana data is stored in a persistent Docker volume named `grafana-storage`. To
+create a backup of this, use
+
+```sh
+docker run --rm \
+ --mount source=grafana-storage,target=/g \
+ -v $(pwd):/backup \
+ busybox \
+ tar -cvzf /backup/grafana-storage.backup.tar.gz /g
+```
+
+## Installation
+
+Restore the volume:
+
+```sh
+docker run --rm \
+ --mount source=grafana-storage,target=/g \
+ -v $(pwd):/backup \
+ busybox \
+ tar -xvzf /backup/grafana-storage.backup.tar.gz -C /
+```
+
+Add the Grafana nginx config
+
+```sh
+sudo mv grafana.nginx.conf /root/nginx/conf.d
+```
+
+and reload the nginx service before starting Grafana for the first time.
+
+```sh
+sudo systemctl reload nginx
+sudo systemctl start grafana
+```
diff --git a/infra/services/grafana/grafana.nginx.conf b/infra/services/grafana/grafana.nginx.conf
new file mode 100644
index 0000000000..046f42153c
--- /dev/null
+++ b/infra/services/grafana/grafana.nginx.conf
@@ -0,0 +1,24 @@
+# Needed for web sockets
+map $http_upgrade $connection_upgrade {
+ default upgrade;
+ '' close;
+}
+
+server {
+ listen 443 ssl http2;
+ listen [::]:443 ssl http2;
+ ssl_certificate /etc/ssl/certs/cert.pem;
+ ssl_certificate_key /etc/ssl/private/key.pem;
+
+ server_name grafana.ente.io;
+
+ location / {
+ proxy_pass http://host.docker.internal:3001;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ }
+}
diff --git a/infra/services/grafana/grafana.service b/infra/services/grafana/grafana.service
new file mode 100644
index 0000000000..22003a5bc5
--- /dev/null
+++ b/infra/services/grafana/grafana.service
@@ -0,0 +1,14 @@
+[Unit]
+Documentation=https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/
+Requires=docker.service
+After=docker.service
+
+[Service]
+ExecStartPre=docker pull grafana/grafana-oss
+ExecStartPre=-docker stop grafana
+ExecStartPre=-docker rm grafana
+ExecStart=docker run --name grafana \
+ -p 3001:3001 \
+ -v grafana-storage:/var/lib/grafana \
+ -e "GF_SERVER_HTTP_PORT=3001" \
+ grafana/grafana-oss