Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Setting Up Grafana

Introduction

Grafana is an open-source platform for monitoring and observability. It allows you to visualize data from various sources and create beautiful dashboards. This tutorial will guide you through the process of setting up Grafana on your server or local machine.

Prerequisites

Before you begin, ensure you have the following:

  • A server or computer with internet access.
  • Access to the command line interface.
  • Basic knowledge of using the terminal.

Step 1: Install Grafana

The installation process will vary depending on your operating system. Below are instructions for different platforms.

For Ubuntu/Debian

Run the following commands in your terminal:

sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:grafana/stable
sudo apt-get update
sudo apt-get install grafana

For CentOS/RHEL

Use the below commands:

sudo yum install -y https://packages.grafana.com/oss/release/grafana-8.0.0-1.x86_64.rpm
sudo systemctl enable grafana-server
sudo systemctl start grafana-server

For Windows

Download the installer from the Grafana downloads page and run the .exe file.

Step 2: Access Grafana

After installation, Grafana runs as a service. You can access the Grafana dashboard by opening your web browser and navigating to:

http://localhost:3000

The default username and password are both admin. You will be prompted to change the password upon first login.

Step 3: Configure Data Sources

Grafana allows you to connect to different data sources. Common data sources include:

  • Prometheus
  • InfluxDB
  • MySQL
  • PostgreSQL

To add a data source, follow these steps:

  1. Click on the gear icon in the left sidebar to access settings.
  2. Select Data Sources.
  3. Click on Add data source.
  4. Choose your desired data source from the list and fill in the required fields.

Step 4: Create Your First Dashboard

Now that you have configured your data sources, you can create a dashboard:

  1. Click on the plus icon (+) in the left sidebar.
  2. Select Dashboard.
  3. Click on Add new panel.
  4. Select the data source you configured earlier.
  5. Build your query and customize the visualization.
  6. Click Apply to save your panel.

Repeat these steps to add more panels to your dashboard.

Step 5: Save and Share Your Dashboard

To save your dashboard, click the disk icon at the top right. You can share your dashboard with others by clicking the share icon and copying the link or exporting it as JSON.

Conclusion

You have successfully set up Grafana and created your first dashboard! Grafana is a powerful tool, and there's much more to explore, including alerts, various visualizations, and plugins. Enjoy monitoring your data!