Troubleshooting Grafana, Loki, and Promtail Connectivity Issues
When your Grafana is on one server and Loki/Promtail on another, but logs aren't visible in Grafana, here's a systematic approach to diagnose and resolve the issue:
1. Verify Promtail is Actually Scraping Logs
First, confirm Promtail is collecting logs:
bash
# On the Promtail server
journalctl -u promtail -f # If using systemd
# Or check Promtail logs directly
tail -f /var/log/promtail.log
Look for lines indicating successful log collection like:
If you've checked all these and still have issues, please provide:
Relevant portions of your Promtail config
Any error messages from logs
Your Grafana Loki data source configuration
Output of the connectivity tests
User
promtail and loki is on windows server
Assistant
Troubleshooting Grafana, Loki, and Promtail on Windows Server
When running Promtail and Loki on Windows Server with Grafana on another machine, here's how to diagnose and resolve visibility issues:
1. Verify Promtail Service Status
powershell
# Check if Promtail service is running
Get-Service | Where-Object {$_.Name -like "*promtail*"}
# View Promtail logs (location depends on your installation)
Get-Content -Path "C:\Program Files\Grafana\promtail\promtail.log" -Tail 50 -Wait
2. Check Promtail Configuration
Verify your Promtail config file (typically C:\Program Files\Grafana\promtail\promtail-config.yaml):
yaml
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: C:\Program Files\Grafana\promtail\positions.yaml
clients:
- url: http://localhost:3100/loki/api/v1/push # Should point to your Loki server
scrape_configs:
- job_name: windows
static_configs:
- targets:
- localhost
labels:
job: windows
__path__: C:\Logs\*.log # Adjust to your log paths
3. Verify Loki Service Status
powershell
# Check if Loki service is running
Get-Service | Where-Object {$_.Name -like "*loki*"}
# View Loki logs
Get-Content -Path "C:\Program Files\Grafana\loki\loki.log" -Tail 50 -Wait
4. Check Network Connectivity
From the Windows server where Promtail is running:
powershell
# Test connection to Loki
Test-NetConnection -ComputerName localhost -Port 3100
# If Loki is on a different machine:
Test-NetConnection -ComputerName <LOKI_SERVER_IP> -Port 3100
5. Windows-Specific Considerations
Firewall Rules:
powershell
# Check if port 3100 is open
Get-NetFirewallRule | Where-Object {$_.LocalPort -eq 3100}
# If needed, add a rule
New-NetFirewallRule -DisplayName "Loki" -Direction Inbound -LocalPort 3100 -Protocol TCP -Action Allow
File Permissions:
Ensure Promtail has read access to the log files
Check the positions.yaml file permissions
Service Accounts:
Verify the services are running under accounts with proper permissions
6. Grafana Configuration
In Grafana (on your other server):
Go to Configuration > Data Sources
Verify the Loki data source URL is correct (e.g., http://<WINDOWS_SERVER_IP>:3100)
Test the connection
7. Common Windows-Specific Issues
Path Issues:
Windows paths in Promtail config must use double backslashes or forward slashes
Example: C:\\Logs\\*.log or C:/Logs/*.log
Service Dependencies:
Ensure Loki is running before Promtail starts
Log Rotation:
Windows log rotation might affect Promtail's ability to track files
8. Debugging Steps
Check Promtail Targets:
powershell
Invoke-RestMethod -Uri "http://localhost:9080/targets" -Method Get
Query Loki Directly:
powershell
Invoke-RestMethod -Uri "http://localhost:3100/loki/api/v1/query?query={job=~`"windows`"}" -Method Get
Check Loki Metrics:
powershell
Invoke-RestMethod -Uri "http://localhost:3100/metrics" -Method Get
9. Recommended Fixes
Update Configuration:
Ensure all paths are properly escaped
Verify network addresses are correct
Restart Services:
powershell
Restart-Service promtail
Restart-Service loki
Check Event Viewer:
Look for application errors related to Promtail or Loki