How to Install Grafana on Ubuntu LTS Linux
How to Install Grafana on Ubuntu LTS Linux
Establish a monitoring system by setting up Grafana, an open-source tool, on your Ubuntu 22.04 or 20.04 server. This tutorial will assist you in implementing data visualization, monitoring, and observability. Grafana, suitable for those seeking a third-party solution, offers a graphical, web-based dashboard for monitoring various data sources. It is available in both an Open Source version, which is free, and an Enterprise edition, which is paid. Grafana is widely utilized for its ability to connect with different data sources like databases, cloud services, and other monitoring systems, enabling the creation of interactive, tailor-made dashboards.Grafana boasts several notable features, such as:
The capability to craft visually attractive charts and graphs using data from multiple sources.
Compatibility with numerous data sources, including well-known databases (e.g., MySQL, PostgreSQL) and cloud platforms (like AWS).
- Functionality for setting up alerts triggered by predefined conditions.
- A user-centric design that allows extensive customization.
- A comprehensive range of plugins and extensions enhancing its functionality.
- A robust community and available support for users.
On the Page:
Steps to configure Grafana on Ubuntu 22.04 or 20.04
Prerequisites:
Step
1: Start with Ubuntu System Update
Step
2: Install the required extra packages
Step
2: Add Grafana GPG key and Repository
Step
3: Installing Grafana on Ubuntru 22.04 or 20.04
Step
4: Start Grafana service and Enable at Boot
Step
5: Allow Grafana port in the Firewall
Step
6: Access the Grafana Web Interface
Step
7: Configure Data Sources and Create Dashboards:
Steps to configure Grafana on Ubuntu 22.04 or 20.04
Prerequisites:
To follow the tutorial, keep a few things ready, here are those:
- Ubuntu server or desktop system.
- User account with Admin (sudo) access.
- Internet connection
Step 1: Start with Ubuntu System Update:
It's important to periodically execute the system update command on a Linux system, particularly before installing new software packages. This process not only ensures that all installed applications are updated to their latest versions, but it also refreshes the APT package index cache. Therefore, you should start by opening the command terminal on your Ubuntu system and executing the appropriate update command.
sudo apt update && sudo apt upgrade
Step 2: Install the required extra packages:
To execute the commands in this tutorial, certain packages are necessary. You can install these packages on your system using the provided syntax commands.
sudo aptinstall -y apt-transport-https
software-properties-common wgetTo set up Grafana on Ubuntu, the APT package manager is used. But first, you must add Grafana's repository and the GPG key, which is used for signing the packages in that repository. This step is necessary because Grafana's packages are not available in the default Ubuntu repositories.
First, let’s add the GPG key.
sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
Now, add the repository:
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
Step 3: Installing Grafana on Ubuntru 22.04 or 20.04
After following the previous steps and executing the given commands, your Ubuntu system will be prepared to install Grafana. However, it's important to rerun the system update command before proceeding. This is necessary because you've added a new repository, and refreshing the APT package index cache is essential for recognizing the new packages available for installation.
sudo apt update
Now, use APT to install the latest Grafana open source or community edition:
sudo aptinstall grafanaoptional) Those, who are interested in the latest Enterprise edition (paid), can run this command instead of the above one:
sudoaptinstallgrafana-enterprise
Step 4: Start Grafana service and Enable at Boot:
During the installation of Grafana, a service file is automatically created on your Ubuntu system. This file can be used to start or stop the Grafana service as needed. Additionally, if you want Grafana to start automatically when the system boots, you have the option to enable its service.
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
To check the service status, we can use:
sudo systemctl status grafana-server --no-pager -l
Step 5: Allow Grafana port in the Firewall:
The Grafana Dashboard can be accessed easily from a local machine using a web browser. However, in cases where you're working with a CLI-based server, accessing the dashboard requires using a browser on a different computer. To facilitate remote access to Grafana's web-based monitoring dashboard, it's necessary to allow traffic through port number 3000 in your firewall settings.
sudo ufw allow 3000/tcp
ufw allow 3000/tcpWhereas, if you are using some cloud service such as AWS or Google Cloud then open the port in the firewall provided by the server provider.
To change the port number, if required
If the 3000 port is already used with another service on your system then you will get an Empty reply from the Grafana server. In such cases use some custom port.
Note: To use a custom
port edit the Grafana config file- sudo nano /usr/share/grafana/conf/defaults.ini and there, change the http_port = 3000 value.
sudo systemctl
restart grafana-server Step 6: Access the Grafana Web Interface:
Having completed the installation, it's time to access Grafana's graphical user interface for further configuration. On any system that has network access to the server where Grafana is installed, open a web browser. Then, in the address bar, enter the server's IP address followed by the port number 3000 to access the Grafana dashboard.
For example:
http://your_server_ip:3000
The default Grafana web interface login credentials are as follows:
Username: adminYou’ll be prompted to change the password after the first login.
Password: admin
Step 7: Configure Data Sources and Create Dashboards:
After logging into Grafana, you can begin setting up data sources and crafting dashboards. This process enables you to visualize data from different sources and establish monitoring and alerts according to your requirements.
No comments: