Step-by-Step Guide
- Update the Package Index
Open a terminal and update the package index to ensure you have the latest information about available packages:
sudo apt update
- Install Dependencies
Install the necessary dependencies for Grafana:
sudo apt install -y software-properties-common
- Add the Grafana APT Repository
Add the Grafana APT repository to your system:
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
- Add the Grafana GPG Key
Add the Grafana GPG key to your system:
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
- Update the Package Index Again
Update the package index to include the Grafana repository:
sudo apt update
- Install Grafana
Install Grafana using theapt
package manager:
sudo apt install grafana
- Start and Enable Grafana
Start the Grafana service:
sudo systemctl start grafana-server
Enable Grafana to start on boot:
sudo systemctl enable grafana-server
- Verify Grafana Installation
Check the Grafana service status to ensure it is running:
sudo systemctl status grafana-server
If Grafana is running, you should see an active (running) status.
- Access the Grafana Web Interface
Open your web browser and navigate tohttp://your_server_ip:3000
. You should see the Grafana login screen. - Log In to Grafana
The default username and password for Grafana are bothadmin
. Log in using these credentials. You will be prompted to change the default password after the first login. - Add a Data Source
After logging in, you need to add a data source. Click on the gear icon (Configuration) on the left sidebar, then select “Data Sources” and click “Add data source”. Select your preferred data source type (e.g., Prometheus, MySQL, PostgreSQL) and configure the connection settings. - Create a Dashboard
To create a new dashboard, click on the plus icon (+) on the left sidebar, then select “Dashboard” and click “Add new panel”. You can add various panels (graphs, tables, etc.) and configure them to display data from your data source. - Install Grafana Plugins (Optional)
Grafana supports various plugins. To install a plugin, use the Grafana CLI. For example, to install thegrafana-piechart-panel
plugin:sudo grafana-cli plugins install grafana-piechart-panel
Restart Grafana to apply the changes:sudo systemctl restart grafana-server
- Configure Grafana (Optional)
You can configure Grafana settings by editing the Grafana configuration file located at/etc/grafana/grafana.ini
. After making changes, restart Grafana to apply them:sudo nano /etc/grafana/grafana.ini sudo systemctl restart grafana-server
- Secure Grafana (Optional)
For additional security, consider enabling HTTPS for Grafana. Obtain an SSL certificate (e.g., using Let’s Encrypt) and configure Grafana to use it by editing the configuration file:ini
[server]
protocol = https cert_file = /path/to/your/cert.crt cert_key = /path/to/your/cert.key