Grafana Dashboard Creation

Grafana Dashboard Creation

To create a Grafana dashboard that visualizes metrics collected by Prometheus, follow these steps to install Grafana, configure it to use Prometheus as a data source, and create a dashboard.

Step 1: Install Grafana

  1. Download and Install Grafana: Grafana can be installed using various methods. Here’s how to install it on different platforms:

    For Ubuntu/Debian:

     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:

     sudo yum install -y https://rpm.grafana.com/grafana/rpm/grafana-<version>.rpm
    

    Replace <version> with the latest version number.

    For Windows: Download the installer from the Grafana download page and run it.

  2. Start Grafana: After installation, you can start Grafana with the following command:

    For Linux:

     sudo systemctl start grafana-server
     sudo systemctl enable grafana-server
    

    For Windows: Run the Grafana service from the Start menu or using the Windows Service Manager.

  3. Access Grafana: Open your web browser and navigate to http://localhost:3000. The default login credentials are:

    • Username: admin

    • Password: admin (you will be prompted to change this on first login)

Step 2: Configure Prometheus as a Data Source

  1. Add Data Source:

    • After logging in, click on the gear icon (⚙️) in the left sidebar to go to the Configuration section.

    • Click on Data Sources.

    • Click on the Add data source button.

  2. Select Prometheus:

    • Find and select Prometheus from the list of available data sources.
  3. Configure the Prometheus Data Source:

    • Set the HTTP URL to your Prometheus server (e.g., http://localhost:9090).

    • Leave other settings as default and click Save & Test to verify the connection.

Step 3: Create a Dashboard

  1. Create a New Dashboard:

    • Click on the Plus icon (➕) in the left sidebar, and then select Dashboard.
  2. Add a Panel:

    • Click on Add new panel.

    • In the panel editor, you can query metrics collected by Prometheus.

  3. Example Queries: Here are some example queries you can use to visualize CPU usage and memory usage:

    • CPU Usage:

        rate(node_cpu_seconds_total{mode="idle"}[5m])
      

      You may need to adjust this based on your specific metric names.

    • Memory Usage:

        node_memory_Active_bytes / node_memory_MemTotal_bytes * 100
      
  4. Configure Visualization:

    • Choose a visualization type (e.g., graph, gauge, table) from the options at the top.

    • Customize the panel settings (e.g., title, axes, legends) as desired.

  5. Save the Dashboard:

    • Click the disk icon at the top to save your dashboard.

    • Give your dashboard a name and click Save.

Step 4: Add More Panels (Optional)

You can repeat the process of adding new panels with different metrics to visualize various aspects of your Node.js application and system metrics.

Step 5: View Your Dashboard

Once you’ve added your desired panels and saved your dashboard, you can view and interact with it to monitor the metrics collected by Prometheus.

Conclusion

You have successfully installed Grafana, configured it to use Prometheus as a data source, and created a dashboard to visualize CPU usage and memory usage.