Grafana is free software based on the Apache 2.0 license, which enables the visualization and formatting of metric data. It lets you create dashboards and graphs from multiple sources, including time-series databases such as MySQL, Graphite, InfluxDB and OpenTSDB.
In this article, we will explain how to install it on an Ubuntu 20.04 LTS server using NGINX as a reverse proxy and obtaining a certificate with Certbot.
Installing Grafana OSS
First, you will need to obtain the grafana repository key and add it (Ubuntu 20.04 LTS):
# wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -If you are using Ubuntu 22.04 LTS or later, apt-key is deprecated. Use the following command:
# curl -fsSL https://packages.grafana.com/gpg.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/grafana.gpgThen add the Grafana repository:
# echo "deb https://packages.grafana.com/oss/deb stable main" | tee -a /etc/apt/sources.list.d/grafana.listNext, update the repositories and install Grafana:
# apt update && apt install grafana -yOnce installed, reload the daemons:
# systemctl daemon-reloadAnd start the Grafana server:
# systemctl start grafana-serverYou can check the status with:
# systemctl status grafana-serverBut do not forget to enable the service:
# systemctl enable grafana-server.serviceInstalling and configuring NGINX Reverse Proxy
Once you have completed the steps above, install the web server for the proxy:
# apt install nginxCopy the default configuration file:
# cp /etc/nginx/sites-available/default /etc/nginx/sites-available/grafanaAnd edit the configuration file:
# nano /etc/nginx/sites-available/grafanaYou will need to modify server_name to specify the DNS record or records that point to the server:
server_name grafana.dominio.com;Also, to set up the reverse proxy, replace the line:
try_files $uri $uri/ =404;With proxying to the Grafana port:
proxy_pass http://localhost:3000;Reload the NGINX configuration:
# systemctl reload nginx.serviceInstall Certbot with the python package for NGINX:
# apt install python3-certbot-nginx -yFinally, obtain the certificate with Certbot (add more -d records if necessary):
# certbot --nginx --redirect -d grafana.dominio.comThen access it using a web browser with the default Grafana username and password (admin/admin) to change the password as soon as possible for security.
We hope this tutorial has helped you. Have you tried it? Leave us your comments! 🙂
Remember, if you have questions about this or any other issue related to your servers on Clouding, do not hesitate to write to soporte@clouding.io We are here for you whenever you need us!