A simplified guide to automate the installation and configuration of Loki and Promtail for centralized logging with Grafana. This documentation covers setup steps, configuration details, and troubleshooting tips.
This repository provides streamlined scripts to automate the setup of Loki and Promtail, offering centralized logging integrated with Grafana. The scripts are designed for ease of use and allow users to set up Loki and Promtail on any compatible Linux server with minimal manual intervention.
Run the following command to install both Loki and Promtail:
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/install_loki_promtail.sh)"
This command will:
To configure Grafana with Loki as a data source and set up a default dashboard, run:
sudo wget -O middleware.py https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/middleware.py && wget -O loki-dashboard.json https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/loki-dashboard.json && python3 middleware.py"
To configure Grafana with Loki, you need a Bearer Token. Follow these steps to generate one:
Loki-Integration
).Note: Store the token securely, as it grants access to configure Grafana and interact with data sources.
To automatically add Loki as a data source and create a default Grafana dashboard:
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/create_grafana_dashboard.sh)"
For AWS Lambda configuration:
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/create_grafana_dashboard_lamba_fn.sh)"
This script will prompt for:
Once Loki and Promtail are installed and running, access the Loki UI at:
http://<your-server-ip>:3100
Default Credentials:
admin
Check the status of the services:
sudo systemctl status loki
sudo systemctl status promtail
If the services aren’t running, check logs with:
journalctl -u loki
journalctl -u promtail
Verify the Loki URL and credentials in the middleware script. Ensure that the Grafana Bearer Token is valid and has permissions to create data sources.
Check the data source in Grafana: