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 π
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. π οΈ
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 passwordadmin
. You'll be prompted to change the password. π
Step 2: Create a Dashboard π
Add a New Dashboard:
In the Grafana sidebar, hover over the Create (plus sign) icon and click Dashboard. β
Click Add a new panel. πΌοΈ
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. π
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. πΎ
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:
Set up Grafana on an AWS EC2 instance. π₯οΈ
Create a new dashboard and add a panel. π
Configure a query and customize your panel. π οΈ
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! π¨π©βπ»π¨βπ»