add final changes
This commit is contained in:
@@ -0,0 +1,95 @@
|
|||||||
|
# Monitoring Stack with Grafana, Prometheus, Loki & Alloy
|
||||||
|
|
||||||
|
This repository contains a complete monitoring stack for visualizing metrics and logs from containers and host systems using Docker Compose.
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
- **Grafana**: Visualization and dashboarding (port 3000)
|
||||||
|
- **Prometheus**: Metrics collection and storage (port 9090)
|
||||||
|
- **Loki**: Log aggregation system (port 3100)
|
||||||
|
- **Alloy**: Grafana complementary observability system (port 12345)
|
||||||
|
- **Node Exporter**: Host metrics exporter (port 9100)
|
||||||
|
- **cAdvisor**: Container metrics exporter (port 8080)
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start the monitoring stack
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# Stop the stack
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
## Services Access
|
||||||
|
|
||||||
|
- **Grafana**: http://localhost:9010 (user: admin, password: password)
|
||||||
|
- **Prometheus**: http://localhost:9040
|
||||||
|
- **Loki**: http://localhost:9020
|
||||||
|
- **cAdvisor**: http://localhost:9050
|
||||||
|
- **Node Exporter**: http://localhost:9060
|
||||||
|
- **Alloy**: http://localhost:9030
|
||||||
|
|
||||||
|
## Directory Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── config/
|
||||||
|
│ ├── alloy.conf # Alloy configuration
|
||||||
|
│ ├── loki.yml # Loki configuration
|
||||||
|
│ ├── prometheus.yml # Prometheus configuration
|
||||||
|
│ ├── prometheus-alerts.yml # Prometheus alerting rules
|
||||||
|
│ └── provisioning/
|
||||||
|
│ ├── dashboards/ # Grafana dashboard provisioning
|
||||||
|
│ │ ├── dashboard-provider.yml # Dashboard provider config
|
||||||
|
│ │ └── node-exporter-full.json # Node Exporter dashboard
|
||||||
|
│ └── datasources/ # Grafana datasource provisioning
|
||||||
|
│ └── grafana-datasources.yml # Datasource config
|
||||||
|
├── docker-compose.yml # Docker Compose configuration
|
||||||
|
└── README.md # This file
|
||||||
|
```
|
||||||
|
|
||||||
|
## Preconfigured Features
|
||||||
|
|
||||||
|
- **Dashboards**: Node Exporter Full dashboard pre-installed
|
||||||
|
- **Datasources**: Prometheus and Loki automatically configured
|
||||||
|
- **Alerts**: Basic host and container alerts configured in Prometheus
|
||||||
|
- **Metrics**: Host and container metrics automatically collected
|
||||||
|
- **Persistent Storage**: All data stored in Docker volumes
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Modifying Prometheus Targets
|
||||||
|
|
||||||
|
Edit `config/prometheus.yml` to add additional scrape targets.
|
||||||
|
|
||||||
|
### Adding Grafana Dashboards
|
||||||
|
|
||||||
|
Place JSON dashboard files in `config/provisioning/dashboards/` and restart the stack.
|
||||||
|
|
||||||
|
### Alerting Rules
|
||||||
|
|
||||||
|
Edit `config/prometheus-alerts.yml` to modify alerting rules.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**Dashboards not showing up:**
|
||||||
|
- Check Grafana logs: `docker-compose logs grafana`
|
||||||
|
- Verify directory structure matches documentation
|
||||||
|
- Ensure dashboard JSON files are valid
|
||||||
|
|
||||||
|
**Service won't start:**
|
||||||
|
- Check for port conflicts
|
||||||
|
- Verify all required files exist in the correct locations
|
||||||
|
- Check individual service logs: `docker-compose logs [service_name]`
|
||||||
|
|
||||||
|
## Security Notes
|
||||||
|
|
||||||
|
This setup uses default credentials and is intended for local development or testing. For production use:
|
||||||
|
- Change default Grafana password
|
||||||
|
- Set up proper authentication for all services
|
||||||
|
- Use secrets management for credentials
|
||||||
|
- Configure TLS for all exposed endpoints
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
apiVersion: 1
|
apiVersion: 1
|
||||||
|
|
||||||
providers:
|
providers:
|
||||||
- name: 'Node Exporter Full'
|
- name: 'Default'
|
||||||
orgId: 1
|
orgId: 1
|
||||||
folder: ''
|
folder: ''
|
||||||
type: file
|
type: file
|
||||||
disableDeletion: false
|
disableDeletion: false
|
||||||
updateIntervalSeconds: 10
|
updateIntervalSeconds: 10
|
||||||
allowUiUpdates: false
|
allowUiUpdates: true
|
||||||
options:
|
options:
|
||||||
path: /etc/grafana/dashboards
|
path: /var/lib/grafana/dashboards
|
||||||
|
|||||||
+10
-8
@@ -4,15 +4,17 @@ services:
|
|||||||
image: grafana/grafana:latest
|
image: grafana/grafana:latest
|
||||||
container_name: grafana
|
container_name: grafana
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "9010:3000"
|
||||||
environment:
|
environment:
|
||||||
- GF_SECURITY_ADMIN_USER=admin
|
- GF_SECURITY_ADMIN_USER=admin
|
||||||
- GF_SECURITY_ADMIN_PASSWORD=password # Change this in production
|
- GF_SECURITY_ADMIN_PASSWORD=password # Change this in production
|
||||||
- GF_USERS_ALLOW_SIGN_UP=false
|
- GF_USERS_ALLOW_SIGN_UP=false
|
||||||
volumes:
|
volumes:
|
||||||
- grafana-data:/var/lib/grafana
|
- grafana-data:/var/lib/grafana
|
||||||
- ./config/provisioning:/etc/grafana/provisioning
|
- ./config/provisioning/dashboards:/etc/grafana/provisioning/dashboards
|
||||||
- ./config/dashboards:/etc/grafana/dashboards
|
- ./config/provisioning/datasources:/etc/grafana/provisioning/datasources
|
||||||
|
# Add this new mount to store the actual dashboard JSON
|
||||||
|
- ./config/provisioning/dashboards:/var/lib/grafana/dashboards
|
||||||
depends_on:
|
depends_on:
|
||||||
- loki
|
- loki
|
||||||
- prometheus
|
- prometheus
|
||||||
@@ -24,7 +26,7 @@ services:
|
|||||||
image: grafana/loki:latest
|
image: grafana/loki:latest
|
||||||
container_name: loki
|
container_name: loki
|
||||||
ports:
|
ports:
|
||||||
- "3100:3100"
|
- "9020:3100"
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/loki.yml:/etc/loki/local-config.yaml
|
- ./config/loki.yml:/etc/loki/local-config.yaml
|
||||||
- loki-data:/var/loki
|
- loki-data:/var/loki
|
||||||
@@ -37,7 +39,7 @@ services:
|
|||||||
image: grafana/alloy:latest
|
image: grafana/alloy:latest
|
||||||
container_name: grafana-alloy
|
container_name: grafana-alloy
|
||||||
ports:
|
ports:
|
||||||
- "12345:12345"
|
- "9030:12345"
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/alloy.conf:/etc/alloy/config.alloy
|
- ./config/alloy.conf:/etc/alloy/config.alloy
|
||||||
- alloy-data:/var/lib/alloy/data
|
- alloy-data:/var/lib/alloy/data
|
||||||
@@ -55,7 +57,7 @@ services:
|
|||||||
image: prom/prometheus:latest
|
image: prom/prometheus:latest
|
||||||
container_name: prometheus
|
container_name: prometheus
|
||||||
ports:
|
ports:
|
||||||
- "9090:9090"
|
- "9040:9090"
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml
|
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||||
- ./config/prometheus-alerts.yml:/etc/prometheus/alerts.yml
|
- ./config/prometheus-alerts.yml:/etc/prometheus/alerts.yml
|
||||||
@@ -81,7 +83,7 @@ services:
|
|||||||
- /var/lib/docker/:/var/lib/docker:ro
|
- /var/lib/docker/:/var/lib/docker:ro
|
||||||
- /dev/disk/:/dev/disk:ro
|
- /dev/disk/:/dev/disk:ro
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "9050:8080"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- monitoring
|
- monitoring
|
||||||
@@ -102,7 +104,7 @@ services:
|
|||||||
- '--path.sysfs=/host/sys'
|
- '--path.sysfs=/host/sys'
|
||||||
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
|
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
|
||||||
ports:
|
ports:
|
||||||
- "9100:9100"
|
- "9060:9100"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- monitoring
|
- monitoring
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
apiVersion: 1
|
|
||||||
|
|
||||||
providers:
|
|
||||||
- name: 'Node Exporter Full'
|
|
||||||
orgId: 1
|
|
||||||
folder: ''
|
|
||||||
type: file
|
|
||||||
disableDeletion: false
|
|
||||||
updateIntervalSeconds: 10
|
|
||||||
allowUiUpdates: false
|
|
||||||
options:
|
|
||||||
path: /etc/grafana/dashboards
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
apiVersion: 1
|
|
||||||
|
|
||||||
datasources:
|
|
||||||
- name: Prometheus
|
|
||||||
type: prometheus
|
|
||||||
access: proxy
|
|
||||||
url: http://prometheus:9090
|
|
||||||
isDefault: true
|
|
||||||
version: 1
|
|
||||||
editable: true
|
|
||||||
|
|
||||||
- name: Loki
|
|
||||||
type: loki
|
|
||||||
access: proxy
|
|
||||||
url: http://loki:3100
|
|
||||||
version: 1
|
|
||||||
editable: true
|
|
||||||
jsonData:
|
|
||||||
maxLines: 1000
|
|
||||||
Reference in New Issue
Block a user