Grafana is an open-source platform for data visualization and monitoring. It allows you to create and share dashboards with your team, and it integrates with a wide range of data sources, including InfluxDB, Prometheus, and Elasticsearch. In this article, we will show you how to install Grafana on Rocky Linux 8.
- Before you can install Grafana, you need to make sure that your Rocky Linux 8 system is up to date. Run the following command to update the package index:
sudo dnf update
- Next, you need to add the Grafana package repository to your system. This will allow you to install the latest version of Grafana using the
dnf
package manager. To add the repository, run the following command:
sudo dnf install <https://dl.grafana.com/oss/release/grafana-repo-1.1-1.x86_64.rpm>
- Once the repository is added, you can install Grafana by running the following command:
sudo dnf install grafana
- After the installation is complete, you can start the Grafana service and enable it to start at boot time by running the following commands:
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
- With the Grafana service running, you can access the Grafana web interface by opening a web browser and navigating to
http://localhost:3000
. This will bring up the Grafana login page. - To log in to the Grafana web interface, you will need to use the default username and password, which are
admin
andadmin
, respectively. Once you have logged in, you will be prompted to change the password. - After logging in, you will be taken to the Grafana dashboard, which is the starting point for creating and managing your dashboards. From here, you can add data sources, create dashboards, and explore the various features of Grafana.
To configure Grafana, you can use the web interface or the grafana-cli
command-line tool. Here are a few examples of how to use these tools to configure Grafana:
- To add a data source in the Grafana web interface, go to the “Data Sources” section and click the “Add data source” button. This will bring up a form where you can enter the details for your data source, such as the type, name, URL, and authentication credentials. Once you have entered the details, click the “Save & Test” button to save the data source and test the connection.
- To create a dashboard in the Grafana web interface, go to the “Dashboards” section and click the “Create dashboard” button. This will bring up a form where you can enter the details for your dashboard, such as the title, theme, and time range. Once you have entered the details, click the “Save” button to save the dashboard.
- To set the default time range for all dashboards in the Grafana web interface, go to the “Preferences” section and click the “Default time range” tab. This will bring up a form where you can select the default time range, such as the last hour, day, week, or month. Once you have selected the time range, click the “Save” button to save the changes.
- To add a data source using the
grafana-cli
command-line tool, you can use theadd-data-source
command. For example, to add an InfluxDB data source named “influxdb”, you can run the following command:
Copy code
grafana-cli data-sources add-data-source influxdb \\
--type=influxdb \\
--url=http://localhost:8086 \\
--database=mydb \\
--user=myuser \\
--password=mypassword
This will add an InfluxDB data source named “influxdb” to Grafana using the specified URL, database, and authentication credentials.
- To create a dashboard using the
grafana-cli
command-line tool, you can use thecreate-dashboard
command. For example, to create a dashboard named “mydashboard” with a single panel showing the number of HTTP requests per minute, you can run the following command:
Copy code
grafana-cli dashboards create-dashboard mydashboard \\
--title="My Dashboard" \\
--panel="{\\"datasource\\":\\"influxdb\\",\\"targets\\":[{\\"measurement\\":\\"http_requests\\",\\"fields\\":[\\"value\\"]}],\\"type\\":\\"graph\\"}"
This will create a new dashboard named “mydashboard” with a single panel showing the number of HTTP requests per minute, using the “influxdb” data source.
These are just a few examples of how to configure Grafana using the web interface and the grafana-cli
command-line tool. For more information and a complete list of options, you can refer to the Grafana documentation.
Congratulations! You have successfully installed Grafana on Rocky Linux 8 and logged in to the web interface. You can now start using Grafana to create and manage your dashboards.