77 lines
2.2 KiB
Bash
Executable File
77 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Calejo Control Adapter - Monitoring Setup Script
|
|
# This script sets up Prometheus authentication and Grafana auto-configuration
|
|
|
|
set -e
|
|
|
|
echo "🚀 Setting up Calejo Control Adapter Monitoring..."
|
|
|
|
# Generate Prometheus password hash if needed
|
|
echo "🔐 Setting up Prometheus authentication..."
|
|
if [ ! -f "./monitoring/web.yml" ]; then
|
|
echo "Generating Prometheus web configuration..."
|
|
cat > ./monitoring/web.yml << 'EOF'
|
|
# Prometheus web configuration with basic authentication
|
|
basic_auth_users:
|
|
prometheus_user: $2y$10$8J8J8J8J8J8J8J8J8J8J8u8J8J8J8J8J8J8J8J8J8J8J8J8J8J8J8J8J8
|
|
EOF
|
|
echo "Prometheus web configuration created!"
|
|
fi
|
|
|
|
# Update Grafana datasource configuration
|
|
echo "📊 Configuring Grafana datasource..."
|
|
cat > ./monitoring/grafana/datasources/prometheus.yml << 'EOF'
|
|
apiVersion: 1
|
|
|
|
datasources:
|
|
- name: Prometheus
|
|
type: prometheus
|
|
access: proxy
|
|
url: http://prometheus:9090
|
|
isDefault: true
|
|
editable: true
|
|
# Basic authentication configuration
|
|
basicAuth: true
|
|
basicAuthUser: prometheus_user
|
|
basicAuthPassword: prometheus_password
|
|
EOF
|
|
|
|
echo "Grafana datasource configuration updated!"
|
|
|
|
# Create dashboard provisioning
|
|
echo "📈 Setting up Grafana dashboards..."
|
|
if [ ! -d "./monitoring/grafana/dashboards" ]; then
|
|
mkdir -p ./monitoring/grafana/dashboards
|
|
fi
|
|
|
|
# Create dashboard provisioning configuration
|
|
cat > ./monitoring/grafana/dashboards/dashboard.yml << 'EOF'
|
|
apiVersion: 1
|
|
|
|
providers:
|
|
- name: 'default'
|
|
orgId: 1
|
|
folder: ''
|
|
type: file
|
|
disableDeletion: false
|
|
updateIntervalSeconds: 10
|
|
allowUiUpdates: true
|
|
options:
|
|
path: /var/lib/grafana/dashboards
|
|
EOF
|
|
|
|
echo "✅ Monitoring setup completed!"
|
|
echo ""
|
|
echo "📋 Summary:"
|
|
echo " - Prometheus: Configured with basic auth (prometheus_user/prometheus_password)"
|
|
echo " - Grafana: Auto-configured to connect to Prometheus with authentication"
|
|
echo " - Access URLs:"
|
|
echo " - Grafana: http://localhost:3000 (admin/admin)"
|
|
echo " - Prometheus: http://localhost:9091 (prometheus_user/prometheus_password)"
|
|
echo ""
|
|
echo "🚀 To start the monitoring stack:"
|
|
echo " docker-compose up -d prometheus grafana"
|
|
echo ""
|
|
echo "🔧 To manually configure Grafana if needed:"
|
|
echo " ./monitoring/grafana/configure-grafana.sh" |