Day 74 - Connecting EC2 with Grafana

2 min read

Connect a Linux and one Windows EC2 instance with Grafana and monitor the different components of the server.

Prerequisites:

  1. You should have two EC2 instances: one running Linux (e.g., Amazon Linux or Ubuntu) and another running Windows Server.

  2. Both instances should have internet connectivity.

  3. Basic knowledge of AWS services, SSH for Linux, and RDP for Windows.

Step 1: Install Grafana on Linux EC2 Instance:

  1. SSH into your Linux EC2 instance.

  2. Update the package list and install Grafana:

     sudo apt-get update
     sudo apt-get install -y software-properties-common
     sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
     wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
     sudo apt-get update
     sudo apt-get install grafana
    
  3. Start and enable Grafana service:

     sudo systemctl start grafana-server
     sudo systemctl enable grafana-server
    
  4. Open a web browser and access Grafana at http://:3000. Default login credentials are admin/admin.

Step 2: Set Up Data Sources in Grafana:

  1. Log in to Grafana and go to "Configuration" > "Data Sources."

  2. Click on "Add data source" and configure the data source for your Linux server. You can use various data sources like Prometheus, InfluxDB, etc., depending on your monitoring requirements.

  3. Repeat the same process to configure the data source for your Windows server.

Step 3: Install Monitoring Agents on Linux and Windows:

  1. For Linux, you can use tools like Prometheus Node Exporter and install it on your Linux EC2 instance. Follow the official documentation for installation.

  2. For Windows, you can use Windows Performance Counters or WMI exporters. Install one of these exporters on your Windows EC2 instance and configure it to export metrics to your Grafana data source.

Step 4: Create Dashboards and Panels in Grafana:

  1. Go to "Create" > "Dashboard" and add a new dashboard.

  2. Click on "Add new panel" and choose a visualization type (e.g., Graph, Singlestat, etc.).

  3. Configure your panel to use the appropriate data source and query the metrics you want to monitor.

Step 5: Monitor Components:

You can set up different panels to monitor various components of your Linux and Windows servers, such as CPU usage, memory usage, disk I/O, network traffic, and custom application-specific metrics.

happy learning!!