Last modified by Alexandru Pentilescu on 2024/07/22 21:37

From version 11.1
edited by Alexandru Pentilescu
on 2024/07/22 21:24
Change comment: There is no comment for this version
To version 12.1
edited by Alexandru Pentilescu
on 2024/07/22 21:37
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -281,7 +281,64 @@
281 281  systemctl enable prometheus
282 282  systemctl start prometheus
283 283  {{/code}}
284 -
284 +
285 +After everything has been done, we can proceed with Grafana itself.
286 +
287 +== Installing Grafana ==
288 +Ideally Grafana should be installed from its own APT repository, as this will keep it updated constantly. To do so:
289 +
290 +{{code language="bash"}}
291 +apt-get install -y apt-transport-https software-properties-common wget
292 +mkdir -p /etc/apt/keyrings/
293 +wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/grafana.gpg > /dev/null
294 +echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list
295 +apt-get update
296 +apt-get install grafana
297 +{{/code}}
298 +
299 +== Configuring Grafana ==
300 +After Grafana has been installed, we should make sure that it works properly by changing its default port from port 3000 to 4000 (as port 3000 is normally used by Gitea on our instance).
301 +
302 +To do so, please edit /etc/grafana/grafana.ini by uncommenting the following line and changing the port number to:
303 +
304 +{{code language="ini"}}
305 +http_port = 4000
306 +{{/code}}
307 +
308 +Once this is done, enable the grafana-server service and start it:
309 +
310 +{{code language="bash"}}
311 +systemctl daemon-reload && systemctl enable grafana-server && systemctl start grafana-server.service
312 +{{/code}}
313 +
314 +== Expose the newly created port as an nginx subdomain ==
315 +
316 +Finally, configure an nginx service file for it. Create an /etc/nginx/sites-available/grafana.conf file with the following contents:
317 +
318 +{{code language="nxinx"}}
319 +server {
320 + server_name stats.transistor.one;
321 +
322 + listen [::]:443 ssl http2; # managed by Certbot
323 + listen 443 ssl http2; # managed by Certbot
324 +
325 + include /etc/nginx/snippets/ssl.conf;
326 +
327 + location / {
328 + proxy_set_header Host $http_host;
329 + proxy_pass http://localhost:4000;
330 + }
331 +}
332 +{{/code}}
333 +
334 +Apparently the proxy_set_header directive is necessary to avoid some weird error when trying to set a new password.
335 +
336 +== Set up the environment ==
337 +From this point on, all that's left is to login to stats.transistor.one and set up a new account. The default credentials to do so are username: admin and password: admin. You should change those immediately so that they will not get abused.
338 +
339 +Once that's done, configure your own dashboard and make it work. Personally, I like to import a public dashboard called Node Exporter Full, which looks very cool.
340 +
341 +Happy coding!
285 285  )))
286 286  
287 287