17. docker deployment

This commit is contained in:
Dobromir Popov
2025-08-05 01:22:27 +03:00
parent fa972ace8a
commit 71442f766c
17 changed files with 2925 additions and 269 deletions

170
COBY/docker/.env.example Normal file
View File

@ -0,0 +1,170 @@
# COBY Multi-Exchange Data Aggregation System Environment Configuration
# Copy this file to .env and customize the values
# =============================================================================
# DATABASE CONFIGURATION
# =============================================================================
DB_HOST=timescaledb
DB_PORT=5432
DB_NAME=market_data
DB_USER=market_user
DB_PASSWORD=market_data_secure_pass_2024
DB_SCHEMA=market_data
DB_POOL_SIZE=10
DB_MAX_OVERFLOW=20
DB_POOL_TIMEOUT=30
# =============================================================================
# REDIS CONFIGURATION
# =============================================================================
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=market_data_redis_2024
REDIS_DB=0
REDIS_MAX_CONNECTIONS=50
REDIS_SOCKET_TIMEOUT=5
REDIS_CONNECT_TIMEOUT=5
# =============================================================================
# APPLICATION CONFIGURATION
# =============================================================================
ENVIRONMENT=production
DEBUG=false
LOG_LEVEL=INFO
LOG_FILE=logs/coby.log
LOG_MAX_SIZE=100
LOG_BACKUP_COUNT=5
ENABLE_CORRELATION_ID=true
# =============================================================================
# API CONFIGURATION
# =============================================================================
API_HOST=0.0.0.0
API_PORT=8080
WS_PORT=8081
DASHBOARD_PORT=3000
CORS_ORIGINS=*
RATE_LIMIT=100
MAX_WS_CONNECTIONS=1000
# =============================================================================
# EXCHANGE CONFIGURATION
# =============================================================================
MAX_CONNECTIONS_PER_EXCHANGE=5
RECONNECT_DELAY=5
MAX_RECONNECT_ATTEMPTS=10
HEARTBEAT_INTERVAL=30
# Supported exchanges (comma-separated)
EXCHANGES=binance,coinbase,kraken,bybit,okx,huobi,kucoin,gateio,bitfinex,mexc
# Trading symbols (comma-separated)
SYMBOLS=BTCUSDT,ETHUSDT
# =============================================================================
# AGGREGATION CONFIGURATION
# =============================================================================
BUCKET_SIZE=1.0
HEATMAP_DEPTH=50
UPDATE_FREQUENCY=0.5
VOLUME_THRESHOLD=0.01
# =============================================================================
# PERFORMANCE CONFIGURATION
# =============================================================================
DATA_BUFFER_SIZE=10000
BATCH_WRITE_SIZE=1000
MAX_MEMORY_USAGE=2048
GC_THRESHOLD=0.8
PROCESSING_TIMEOUT=10
MAX_QUEUE_SIZE=50000
# =============================================================================
# MONITORING CONFIGURATION
# =============================================================================
PROMETHEUS_PORT=9090
GRAFANA_PORT=3001
GRAFANA_PASSWORD=admin
# Metrics collection interval (seconds)
METRICS_COLLECTION_INTERVAL=1.0
# Performance thresholds
MAX_CPU_USAGE=80.0
MAX_MEMORY_USAGE_PERCENT=85.0
MIN_MEMORY_AVAILABLE_GB=1.0
MAX_LATENCY_MS=100.0
MAX_ERROR_RATE_PERCENT=5.0
MIN_THROUGHPUT_OPS=100.0
# =============================================================================
# DOCKER CONFIGURATION
# =============================================================================
# Container resource limits
COBY_APP_MEMORY=2g
COBY_APP_CPUS=2.0
TIMESCALEDB_MEMORY=1g
TIMESCALEDB_CPUS=1.0
REDIS_MEMORY=512m
REDIS_CPUS=0.5
# Network configuration
DOCKER_NETWORK_SUBNET=172.20.0.0/16
# =============================================================================
# DEVELOPMENT CONFIGURATION
# =============================================================================
# Override for development environment
DEV_DB_NAME=market_data_dev
DEV_DB_PASSWORD=dev_password
DEV_REDIS_PASSWORD=dev_redis
DEV_API_PORT=8080
DEV_WS_PORT=8081
DEV_DASHBOARD_PORT=3000
# =============================================================================
# SECURITY CONFIGURATION
# =============================================================================
# API Keys for exchanges (optional, for private data)
BINANCE_API_KEY=
BINANCE_API_SECRET=
COINBASE_API_KEY=
COINBASE_API_SECRET=
COINBASE_PASSPHRASE=
KRAKEN_API_KEY=
KRAKEN_API_SECRET=
BYBIT_API_KEY=
BYBIT_API_SECRET=
OKX_API_KEY=
OKX_API_SECRET=
OKX_PASSPHRASE=
HUOBI_API_KEY=
HUOBI_API_SECRET=
KUCOIN_API_KEY=
KUCOIN_API_SECRET=
KUCOIN_PASSPHRASE=
GATEIO_API_KEY=
GATEIO_API_SECRET=
BITFINEX_API_KEY=
BITFINEX_API_SECRET=
MEXC_API_KEY=
MEXC_API_SECRET=
# =============================================================================
# NOTIFICATION CONFIGURATION
# =============================================================================
# Email notifications
SMTP_SERVER=
SMTP_PORT=587
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_FROM_EMAIL=
SMTP_TO_EMAILS=
# Slack notifications
SLACK_WEBHOOK_URL=
SLACK_CHANNEL=
# Webhook notifications
WEBHOOK_URL=
WEBHOOK_HEADERS=

103
COBY/docker/alert_rules.yml Normal file
View File

@ -0,0 +1,103 @@
# Prometheus alert rules for COBY system
groups:
- name: coby_alerts
rules:
# High CPU usage
- alert: HighCPUUsage
expr: system_cpu_usage > 80
for: 2m
labels:
severity: warning
annotations:
summary: "High CPU usage detected"
description: "CPU usage is above 80% for more than 2 minutes"
# High memory usage
- alert: HighMemoryUsage
expr: system_memory_usage > 85
for: 2m
labels:
severity: warning
annotations:
summary: "High memory usage detected"
description: "Memory usage is above 85% for more than 2 minutes"
# Low available memory
- alert: LowAvailableMemory
expr: system_memory_available_gb < 1
for: 1m
labels:
severity: critical
annotations:
summary: "Low available memory"
description: "Available memory is below 1GB"
# High latency
- alert: HighLatency
expr: processing_latency_ms > 100
for: 5m
labels:
severity: warning
annotations:
summary: "High processing latency"
description: "Processing latency is above 100ms for more than 5 minutes"
# Exchange connection failures
- alert: ExchangeConnectionFailure
expr: increase(exchange_connection_errors_total[5m]) > 5
for: 1m
labels:
severity: critical
annotations:
summary: "Exchange connection failures"
description: "More than 5 exchange connection errors in the last 5 minutes"
# Database connection issues
- alert: DatabaseConnectionFailure
expr: database_connection_errors_total > 0
for: 1m
labels:
severity: critical
annotations:
summary: "Database connection failure"
description: "Database connection errors detected"
# High error rate
- alert: HighErrorRate
expr: kpi_error_rate_percent > 5
for: 5m
labels:
severity: warning
annotations:
summary: "High error rate"
description: "Error rate is above 5% for more than 5 minutes"
# Low throughput
- alert: LowThroughput
expr: kpi_throughput_ops_per_sec < 10
for: 10m
labels:
severity: warning
annotations:
summary: "Low system throughput"
description: "System throughput is below 10 ops/sec for more than 10 minutes"
# Service down
- alert: ServiceDown
expr: up == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Service is down"
description: "{{ $labels.job }} service is down"
# Disk space low
- alert: DiskSpaceLow
expr: system_disk_usage > 90
for: 5m
labels:
severity: critical
annotations:
summary: "Disk space low"
description: "Disk usage is above 90%"

View File

@ -1,112 +1,416 @@
#!/bin/bash
# Deployment script for market data infrastructure
# Run this on your Docker host at 192.168.0.10
# COBY Multi-Exchange Data Aggregation System Deployment Script
# This script handles deployment of the COBY system using Docker Compose
set -e
set -e # Exit on any error
echo "🚀 Deploying Market Data Infrastructure..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check if Docker and Docker Compose are available
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed or not in PATH"
exit 1
fi
# Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.yml"
DEV_COMPOSE_FILE="$PROJECT_ROOT/docker-compose.dev.yml"
ENV_FILE="$PROJECT_ROOT/docker/.env"
ENV_EXAMPLE="$PROJECT_ROOT/docker/.env.example"
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "❌ Docker Compose is not installed or not in PATH"
exit 1
fi
# Default values
ENVIRONMENT="production"
PROFILE=""
SERVICES=""
ACTION="up"
DETACHED=true
BUILD=false
PULL=false
FORCE_RECREATE=false
REMOVE_ORPHANS=true
# Set Docker Compose command
if docker compose version &> /dev/null; then
DOCKER_COMPOSE="docker compose"
else
DOCKER_COMPOSE="docker-compose"
fi
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
# Create necessary directories
echo "📁 Creating directories..."
mkdir -p ./data/timescale
mkdir -p ./data/redis
mkdir -p ./logs
mkdir -p ./backups
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
# Set proper permissions
echo "🔐 Setting permissions..."
chmod 755 ./data/timescale
chmod 755 ./data/redis
chmod 755 ./logs
chmod 755 ./backups
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
# Copy environment file if it doesn't exist
if [ ! -f .env ]; then
echo "📋 Creating .env file..."
cp .env.example .env
echo "⚠️ Please edit .env file with your specific configuration"
echo "⚠️ Default passwords are set - change them for production!"
fi
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Pull latest images
echo "📥 Pulling Docker images..."
$DOCKER_COMPOSE -f timescaledb-compose.yml pull
# Function to show usage
show_usage() {
cat << EOF
COBY Deployment Script
# Stop existing containers if running
echo "🛑 Stopping existing containers..."
$DOCKER_COMPOSE -f timescaledb-compose.yml down
Usage: $0 [OPTIONS] [ACTION] [SERVICES...]
# Start the services
echo "🏃 Starting services..."
$DOCKER_COMPOSE -f timescaledb-compose.yml up -d
ACTIONS:
up Start services (default)
down Stop and remove services
restart Restart services
logs Show service logs
ps Show running services
build Build services
pull Pull latest images
exec Execute command in service
health Check service health
# Wait for services to be ready
echo "⏳ Waiting for services to be ready..."
sleep 30
OPTIONS:
-e, --env ENV Environment (production|development) [default: production]
-p, --profile PROFILE Docker compose profile (monitoring|tools)
-d, --detach Run in detached mode [default: true]
-f, --foreground Run in foreground mode
-b, --build Build images before starting
--pull Pull latest images before starting
--force-recreate Force recreate containers
--no-remove-orphans Don't remove orphaned containers
-h, --help Show this help message
# Check service health
echo "🏥 Checking service health..."
EXAMPLES:
$0 # Start production environment
$0 -e development # Start development environment
$0 -p monitoring up # Start with monitoring profile
$0 down # Stop all services
$0 logs coby-app # Show logs for coby-app service
$0 exec coby-app bash # Execute bash in coby-app container
$0 -b up # Build and start services
# Check TimescaleDB
if docker exec market_data_timescaledb pg_isready -U market_user -d market_data; then
echo "✅ TimescaleDB is ready"
else
echo "❌ TimescaleDB is not ready"
exit 1
fi
SERVICES:
coby-app Main application
timescaledb Database
redis Cache
coby-dashboard Web dashboard
prometheus Metrics collection (monitoring profile)
grafana Visualization (monitoring profile)
# Check Redis
if docker exec market_data_redis redis-cli -a market_data_redis_2024 ping | grep -q PONG; then
echo "✅ Redis is ready"
else
echo "❌ Redis is not ready"
exit 1
fi
EOF
}
# Display connection information
echo ""
echo "🎉 Deployment completed successfully!"
echo ""
echo "📊 Connection Information:"
echo " TimescaleDB:"
echo " Host: 192.168.0.10"
echo " Port: 5432"
echo " Database: market_data"
echo " Username: market_user"
echo " Password: (check .env file)"
echo ""
echo " Redis:"
echo " Host: 192.168.0.10"
echo " Port: 6379"
echo " Password: (check .env file)"
echo ""
echo "📝 Next steps:"
echo " 1. Update your application configuration to use these connection details"
echo " 2. Test the connection from your application"
echo " 3. Set up monitoring and alerting"
echo " 4. Configure backup schedules"
echo ""
echo "🔍 To view logs:"
echo " docker-compose -f timescaledb-compose.yml logs -f"
echo ""
echo "🛑 To stop services:"
echo " docker-compose -f timescaledb-compose.yml down"
# Function to check prerequisites
check_prerequisites() {
print_status "Checking prerequisites..."
# Check if Docker is installed and running
if ! command -v docker &> /dev/null; then
print_error "Docker is not installed. Please install Docker first."
exit 1
fi
if ! docker info &> /dev/null; then
print_error "Docker is not running. Please start Docker first."
exit 1
fi
# Check if Docker Compose is available
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
print_error "Docker Compose is not available. Please install Docker Compose."
exit 1
fi
# Determine compose command
if command -v docker-compose &> /dev/null; then
COMPOSE_CMD="docker-compose"
else
COMPOSE_CMD="docker compose"
fi
print_success "Prerequisites check passed"
}
# Function to setup environment file
setup_env_file() {
if [[ ! -f "$ENV_FILE" ]]; then
print_warning "Environment file not found. Creating from example..."
cp "$ENV_EXAMPLE" "$ENV_FILE"
print_status "Please edit $ENV_FILE with your configuration"
print_warning "Using default configuration for now"
else
print_success "Environment file found"
fi
}
# Function to build compose command
build_compose_command() {
local cmd="$COMPOSE_CMD"
# Add compose files
cmd="$cmd -f $COMPOSE_FILE"
if [[ "$ENVIRONMENT" == "development" ]]; then
cmd="$cmd -f $DEV_COMPOSE_FILE"
fi
# Add environment file
cmd="$cmd --env-file $ENV_FILE"
# Add profile if specified
if [[ -n "$PROFILE" ]]; then
cmd="$cmd --profile $PROFILE"
fi
echo "$cmd"
}
# Function to start services
start_services() {
print_status "Starting COBY services in $ENVIRONMENT mode..."
local cmd=$(build_compose_command)
local up_cmd="$cmd up"
if [[ "$BUILD" == true ]]; then
up_cmd="$up_cmd --build"
fi
if [[ "$PULL" == true ]]; then
up_cmd="$up_cmd --pull always"
fi
if [[ "$FORCE_RECREATE" == true ]]; then
up_cmd="$up_cmd --force-recreate"
fi
if [[ "$REMOVE_ORPHANS" == true ]]; then
up_cmd="$up_cmd --remove-orphans"
fi
if [[ "$DETACHED" == true ]]; then
up_cmd="$up_cmd -d"
fi
if [[ -n "$SERVICES" ]]; then
up_cmd="$up_cmd $SERVICES"
fi
eval "$up_cmd"
if [[ "$DETACHED" == true ]]; then
print_success "Services started successfully"
show_service_status
fi
}
# Function to stop services
stop_services() {
print_status "Stopping COBY services..."
local cmd=$(build_compose_command)
eval "$cmd down --remove-orphans"
print_success "Services stopped successfully"
}
# Function to restart services
restart_services() {
print_status "Restarting COBY services..."
local cmd=$(build_compose_command)
if [[ -n "$SERVICES" ]]; then
eval "$cmd restart $SERVICES"
else
eval "$cmd restart"
fi
print_success "Services restarted successfully"
}
# Function to show logs
show_logs() {
local cmd=$(build_compose_command)
if [[ -n "$SERVICES" ]]; then
eval "$cmd logs -f $SERVICES"
else
eval "$cmd logs -f"
fi
}
# Function to show service status
show_service_status() {
print_status "Service status:"
local cmd=$(build_compose_command)
eval "$cmd ps"
}
# Function to build services
build_services() {
print_status "Building COBY services..."
local cmd=$(build_compose_command)
if [[ -n "$SERVICES" ]]; then
eval "$cmd build $SERVICES"
else
eval "$cmd build"
fi
print_success "Services built successfully"
}
# Function to pull images
pull_images() {
print_status "Pulling latest images..."
local cmd=$(build_compose_command)
eval "$cmd pull"
print_success "Images pulled successfully"
}
# Function to execute command in service
exec_command() {
if [[ -z "$SERVICES" ]]; then
print_error "Service name required for exec command"
exit 1
fi
local service=$(echo "$SERVICES" | cut -d' ' -f1)
local command=$(echo "$SERVICES" | cut -d' ' -f2-)
if [[ "$service" == "$command" ]]; then
command="bash"
fi
local cmd=$(build_compose_command)
eval "$cmd exec $service $command"
}
# Function to check service health
check_health() {
print_status "Checking service health..."
local cmd=$(build_compose_command)
local services=$(eval "$cmd ps --services")
for service in $services; do
local health=$(eval "$cmd ps $service" | grep -o "healthy\|unhealthy\|starting" | head -1)
if [[ -n "$health" ]]; then
if [[ "$health" == "healthy" ]]; then
print_success "$service: $health"
elif [[ "$health" == "unhealthy" ]]; then
print_error "$service: $health"
else
print_warning "$service: $health"
fi
else
print_warning "$service: no health check"
fi
done
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-e|--env)
ENVIRONMENT="$2"
shift 2
;;
-p|--profile)
PROFILE="$2"
shift 2
;;
-d|--detach)
DETACHED=true
shift
;;
-f|--foreground)
DETACHED=false
shift
;;
-b|--build)
BUILD=true
shift
;;
--pull)
PULL=true
shift
;;
--force-recreate)
FORCE_RECREATE=true
shift
;;
--no-remove-orphans)
REMOVE_ORPHANS=false
shift
;;
-h|--help)
show_usage
exit 0
;;
up|down|restart|logs|ps|build|pull|exec|health)
ACTION="$1"
shift
;;
*)
SERVICES="$SERVICES $1"
shift
;;
esac
done
# Trim leading/trailing spaces from services
SERVICES=$(echo "$SERVICES" | xargs)
# Main execution
main() {
print_status "COBY Multi-Exchange Data Aggregation System Deployment"
print_status "Environment: $ENVIRONMENT"
if [[ -n "$PROFILE" ]]; then
print_status "Profile: $PROFILE"
fi
if [[ -n "$SERVICES" ]]; then
print_status "Services: $SERVICES"
fi
print_status "Action: $ACTION"
echo
check_prerequisites
setup_env_file
case $ACTION in
up)
start_services
;;
down)
stop_services
;;
restart)
restart_services
;;
logs)
show_logs
;;
ps)
show_service_status
;;
build)
build_services
;;
pull)
pull_images
;;
exec)
exec_command
;;
health)
check_health
;;
*)
print_error "Unknown action: $ACTION"
show_usage
exit 1
;;
esac
}
# Run main function
main

View File

@ -0,0 +1,68 @@
# Nginx configuration for development environment
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Development logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
# Basic settings
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Disable caching for development
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
# Main dashboard
location / {
try_files $uri $uri/ /index.html;
}
# API proxy to COBY app
location /api/ {
proxy_pass http://coby-app:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 86400;
}
# WebSocket proxy
location /ws/ {
proxy_pass http://coby-app:8081/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400;
}
# Health check
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
}

112
COBY/docker/nginx.conf Normal file
View File

@ -0,0 +1,112 @@
# Nginx configuration for COBY dashboard
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
# Basic settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied any;
gzip_comp_level 6;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/json
application/javascript
application/xml+rss
application/atom+xml
image/svg+xml;
# Rate limiting
limit_req_zone $binary_remote_addr zone=dashboard:10m rate=10r/s;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
# Main dashboard
location / {
try_files $uri $uri/ /index.html;
limit_req zone=dashboard burst=20 nodelay;
}
# API proxy to COBY app
location /api/ {
proxy_pass http://coby-app:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 86400;
}
# WebSocket proxy
location /ws/ {
proxy_pass http://coby-app:8081/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400;
}
# Health check
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# Static assets caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Error pages
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}

View File

@ -0,0 +1,53 @@
# Prometheus configuration for COBY monitoring
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
scrape_configs:
# COBY application metrics
- job_name: 'coby-app'
static_configs:
- targets: ['coby-app:8080']
metrics_path: '/metrics'
scrape_interval: 10s
scrape_timeout: 5s
# TimescaleDB metrics (if postgres_exporter is added)
- job_name: 'timescaledb'
static_configs:
- targets: ['timescaledb:5432']
scrape_interval: 30s
scrape_timeout: 10s
# Redis metrics (if redis_exporter is added)
- job_name: 'redis'
static_configs:
- targets: ['redis:6379']
scrape_interval: 30s
scrape_timeout: 10s
# Prometheus self-monitoring
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# Node exporter for system metrics (if added)
- job_name: 'node'
static_configs:
- targets: ['node-exporter:9100']
scrape_interval: 30s
# Alerting configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Alert rules
rule_files:
- "/etc/prometheus/alert_rules.yml"