Day 73 of 90 Days of DevOps Challenge: Setting up Grafana

Task 1: Setting Up Grafana on AWS EC2

Step 1: Launch an EC2 Instance

  1. Log in to the AWS Management Console.

  2. Navigate to the EC2 Dashboard.

  3. Click on "Launch Instance."

  4. Select an Amazon Machine Image (AMI): Choose a suitable AMI, such as Amazon Linux 2 or Ubuntu.

  5. Choose an Instance Type: Select an instance type (e.g., t2.micro) and click "Next."

  6. Configure Instance: Keep the default settings or adjust as needed.

  7. Add Storage: You can keep the default storage size.

  8. Configure Security Group:

    • Create a new security group.

    • Add a rule to allow HTTP (port 80) and Grafana (default port 3000).

    • Allow SSH (port 22) from your IP for remote access.

  9. Review and Launch: Review your settings and launch the instance.

Step 2: Connect to Your EC2 Instance

  1. Use SSH to connect to your instance:

     ssh -i /path/to/your-key.pem ec2-user@your-ec2-public-dns
    

Step 3: Install Grafana

For Amazon Linux 2 or Ubuntu, follow these commands:

  1. Update the package repository:

     sudo yum update -y      # For Amazon Linux
     sudo apt update -y      # For Ubuntu
    
  2. Install Grafana:

     # For Amazon Linux
     sudo yum install -y https://dl.grafana.com/oss/release/grafana-9.4.7-1.x86_64.rpm
     # For Ubuntu
     echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
     sudo apt install -y software-properties-common
     wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
     sudo add-apt-repository -y ppa:grafana/stable
     sudo apt update -y
     sudo apt install -y grafana
    

Step 4: Start and Enable Grafana

  1. Start Grafana service:

     sudo systemctl start grafana-server
    
  2. Enable Grafana to start on boot:

     sudo systemctl enable grafana-server
    

Step 5: Access Grafana

  1. Open your web browser and go to:

     http://your-ec2-public-dns:3000
    
  2. Log in using the default credentials:

    • Username: admin

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

Step 6: Configure Data Sources and Dashboards

  1. After logging in, you can add data sources like Prometheus, InfluxDB, or any other supported databases.

Create dashboards and start visualizing your data!