Day 76 - Build a Grafana Dashboard

Day 76 - Build a Grafana Dashboard

Β·

3 min read

Welcome to Day 76 of the #90DaysOfDevOps challenge! πŸŽ‰ Today, we will be building a Grafana dashboard to visualize your metrics. Grafana is a powerful tool that allows you to create customizable dashboards and track your metrics through different visualizations.

Step-by-Step Guide to Building a Grafana Dashboard

Let's get started! Follow the steps below to create your Grafana dashboard on AWS. πŸš€

Step 1: Set Up Grafana on AWS 🌐

  1. Launch an EC2 Instance:

    • Go to the AWS Management Console. πŸ“œ

    • Navigate to EC2 and click Launch Instance. οΏ½οΏ½

    • Choose an Amazon Machine Image (AMI). For simplicity, select the Amazon Linux 2 AMI. 🐧

    • Choose an instance type (t2.micro is sufficient for this tutorial). πŸ’»

    • Configure instance details, add storage, add tags, and configure the security group to allow inbound traffic on ports 3000 (Grafana) and 22 (SSH). πŸ”’

    • Review and launch the instance. πŸ› οΈ

  2. Install Grafana:

    • SSH into your EC2 instance using the key pair you created during launch. πŸ”‘

    • Update your package list and install Grafana:

        sudo apt-get update
        sudo apt 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 update
        sudo apt install -y grafana
        sudo systemctl start grafana-server
        sudo systemctl enable grafana-server
      
    • Open your browser and navigate to http://<your-ec2-public-ip>:3000. 🌍

    • Log in with the default username admin and password admin. You'll be prompted to change the password. πŸ”

Step 2: Create a Dashboard πŸ“Š

  1. Add a New Dashboard:

    • In the Grafana sidebar, hover over the Create (plus sign) icon and click Dashboard. βž•

    • Click Add a new panel. πŸ–ΌοΈ

  2. Configure the Panel:

    • In the Query editor below the graph, enter the following query and press Shift + Enter:

        sum(rate(tns_request_duration_seconds_count[5m])) by(route)
      
    • In the Legend field, enter {{route}} to rename the time series in the legend. The graph legend updates when you click outside the field. πŸ“

  3. Customize the Panel:

    • In the Panel editor on the right, under Settings, change the panel title to β€œTraffic”. 🚦

    • Click Apply in the top-right corner to save the panel and go back to the dashboard view. πŸ’Ύ

  4. Save the Dashboard:

    • Click the Save dashboard (disk) icon at the top of the dashboard. πŸ’Ύ

    • Enter a name in the Dashboard name field and then click Save. πŸ“

Step 3: Share Your Dashboard 🌍

  • Once you've created your dashboard, share it with the community! πŸ“€

  • You can export your dashboard by clicking the Share button at the top of the dashboard and selecting Export. Share the JSON file or a link to your Grafana instance. πŸ”—

Summary πŸ“œ

Today, you learned how to:

  1. Set up Grafana on an AWS EC2 instance. πŸ–₯️

  2. Create a new dashboard and add a panel. πŸ“Š

  3. Configure a query and customize your panel. πŸ› οΈ

  4. Save and share your dashboard with the community. 🌐

Building dashboards in Grafana allows you to visualize your metrics effectively and keep track of important data at a glance. Keep experimenting with different queries and visualizations to create more insightful dashboards. πŸ’‘

If you have any questions, refer to the Grafana documentation for more details. πŸ“š

Happy visualizing! πŸŽ¨πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!

Β