Day 74 of 90 Days of DevOps Challenge: Connecting your EC2 instance with Grafana

Great job setting up Grafana! Now let's connect your Linux and Windows EC2 instances to Grafana for monitoring.

Task Overview

  1. Connect a Linux EC2 Instance to Grafana:

    • Install Prometheus Node Exporter on the Linux instance.

    • Configure Grafana to use the Node Exporter as a data source.

  2. Connect a Windows EC2 Instance to Grafana:

    • Install the Windows Exporter on the Windows instance.

    • Configure Grafana to use the Windows Exporter as a data source.


Step-by-Step Guide

Part 1: Connect Linux EC2 Instance

  1. SSH into the Linux EC2 Instance:

     ssh -i "your-key.pem" ec2-user@your-linux-ec2-public-ip
    
  2. Install Node Exporter:

     # Download Node Exporter
     wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
    
     # Extract the tar file
     file node_exporter-1.6.1.linux-amd64.tar.gz
     tar xvfz node_exporter-1.6.1.linux-amd64.tar.gz
    
     # Navigate to the extracted directory
     cd node_exporter-1.6.1.linux-amd64
    
     # Run Node Exporter
     ./node_exporter &
    
  3. Open the Required Port (9100):

    • In your EC2 Security Group, allow inbound traffic on port 9100.
  4. Configure Grafana to Use Node Exporter:

    • Open Grafana in your web browser.

    • Go to Configuration > Data Sources > Add Data Source.

    • Choose Prometheus and configure it with the following URL:

        http://your-linux-ec2-public-ip:9100/metrics
      
    • Click Save & Test to ensure the connection is successful.

Part 2: Connect Windows EC2 Instance

  1. Connect to the Windows EC2 Instance:

    • Use Remote Desktop Protocol (RDP) to access your Windows EC2 instance.
  2. Install Windows Exporter:

    • Download the Windows Exporter from the GitHub Releases page.

    • Run the installer and follow the prompts.

  3. Configure Windows Firewall:

    • Ensure that port 9182 is open in the Windows Firewall for inbound traffic.
  4. Configure Grafana to Use Windows Exporter:

    • Similar to the Linux instance, add a new Prometheus data source in Grafana with the following URL:

        http://your-windows-ec2-public-ip:9182/metrics
      
    • Click Save & Test to check the connection.

Monitoring

  • Create dashboards in Grafana using the metrics collected from both instances. You can monitor CPU usage, memory usage, disk space, network activity, etc.

Conclusion

Now you have successfully connected both a Linux and a Windows EC2 instance to Grafana. This setup will enable you to monitor different components of the servers effectively. Let me know if you need help with any specific configurations or dashboard setups!