Introduction:
Welcome to Day 75 of #90daysofdevops! In today we'll be setting up a dashboard to visualize Nginx logs.
Pre-requisites:
Amazon EC2 Instance
Ensure the availability of an Amazon EC2 instance to serve as the host for Docker containers and the monitoring tools.
Grafana, Loki, and Promtail Installed
Install Grafana, Loki, and Promtail to set up the monitoring and log aggregation stack on the EC2 instance.
Grafana: The visualization and monitoring tool.
* Loki: The log aggregation system.
* Promtail: The agent responsible for collecting and forwarding logs to Loki.
If the necessary tools are not installed, follow the step-by-step instructions provided in the referenced blog post for comprehensive guidance.
Certainly! Here are the step-by-step instructions:
Step 1: Install Nginx
sudo apt update
sudo apt install nginx
sudo systemctl start nginx
Step 2: Configure Promtail to Read Nginx Logs
Create a configuration file for Promtail, e.g.,
promtail-config.yml
:server: http_listen_port: 9080 grpc_listen_port: 0 positions: filename: /tmp/positions.yaml clients: - url: http://localhost:3100/loki/api/v1/push scrape_configs: - job_name: nginx static_configs: - targets: - localhost labels: job: nginx __path__: /var/log/nginx/*log
Restart the promtial container
docker restart <continer_id>
Step 3: Open Grafana in the Browser
Access Grafana in your web browser (typically at http://localhost:3000).
Log in with the default credentials (admin/admin).
Step 4: Add Loki as a Data Source
In Grafana, go to "Settings" > "Data Sources" > "Add your first data source."
-
Choose "Loki" from the list.
-
Set the URL to
http://localhost:3100
.
Step 5: Create a Loki Query in Grafana
Go to "Explore" in Grafana.
-
Choose the Loki data source.
Use a query like
{job="nginx"}
to view Nginx logs.
Step 6: Create a Dashboard in Grafana
Go to the "+" menu in Grafana and choose "Dashboard."
-
Click "Add new panel" and select "Loki" as the data source.
Create visualizations and customize your dashboard with Nginx log data.
Conclusion:
Congratulations on successfully setting up the Nginx monitoring dashboard using Grafana, Loki, and Promtail
Connect with me:)
Thank you for diving into this blog with me! I trust you found the information both helpful and enlightening. To stay updated on the latest in DevOps ๐, make sure to follow me. Remember, staying informed means staying ahead in the dynamic world of DevOps!
Feel free to connect with me on:
For more updates and engaging discussions on DevOps, let's connect! ๐ #DevOpsCommunity