This repository automates the setup of Loki and Promtail for centralized logging with Grafana. The scripts in this repository streamline the installation process for Loki and Promtail, and automatically configure Grafana with data sources and dashboards.
- Automated Loki & Promtail Setup: One-click installation for Loki and Promtail.
- Automated Grafana Data Source & Dashboard Configuration: Automatically configure Grafana for Loki.
- Middleware Integration: Middleware for adding and configuring data sources and dashboards in Grafana.
- A Linux-based server (Ubuntu/Debian, CentOS/RHEL, Fedora).
- Grafana running and accessible (this setup assumes Grafana is already installed).
- Python 3.x for middleware (if using the middleware).
- Sudo Privileges: You should have sudo access to install and configure software.
- Installation
- Middleware Setup
- Grafana Data Source & Dashboard Setup
- Accessing Loki UI
- Troubleshooting
- License
To install Loki and Promtail with a single command, run the following:
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/install_loki_promtail.sh)"
This will:
- Automatically detect your system architecture.
- Download and install Loki and Promtail.
- Set up Promtail to run as a service and start on boot.
The middleware helps automatically configure Grafana data sources and dashboards for Loki.
Download and run the middleware script with the following single command:
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/middleware.py)"
This command:
- Downloads the middleware.py script.
- Runs it using Python (ensure you have Python 3.x installed).
The script will ask for the following inputs:
- Grafana URL
- Grafana Bearer Token
- Loki Basic Auth Password
- Middleware URL (for sending configuration data)
This will configure Loki as a data source and create a dashboard in Grafana automatically.
To automatically add Loki as a data source and create a Grafana dashboard, you can use the following single command:
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/create_grafana_dashboard.sh)"
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/abdulsaheel/Loki-Promtail-Setup/refs/heads/main/create_grafana_dashboard_lamba_fn.sh)"
This command:
- Downloads the create_grafana_dashboard.sh script.
- Runs the script to:
- Configure Loki as a data source in Grafana.
- Create a default dashboard for Loki logs.
It will prompt for the following inputs:
- Grafana URL
- Bearer Token
- Loki Basic Auth Password
- Middleware URL
Once Loki and Promtail are installed and running, you can access the Loki UI at:
http://<your-server-ip>:3100
- Username:
admin
(default). - Password: The password you configured during the installation process.
In the Loki UI, you can query logs and visualize them with your Grafana setup.
Check the status of the services:
sudo systemctl status loki
sudo systemctl status promtail
If the services aren’t running, check the logs:
journalctl -u loki
journalctl -u promtail
Ensure that the Loki URL and credentials in the middleware script are correct, and that the Grafana Bearer Token is valid and has the necessary permissions to create data sources.
Verify the data source in Grafana:
- Go to Configuration → Data Sources → Loki.
- Ensure the URL and credentials match the settings from the middleware script.
This project is licensed under the MIT License - see the LICENSE file for details.