Skip to content

Configuration Guide

Learn how to configure ElasticView for your specific environment and requirements.

Configuration Methods

ElasticView supports multiple configuration methods:

  1. Configuration File (recommended)
  2. Environment Variables
  3. Command Line Arguments

Configuration File

Default Location

ElasticView looks for configuration files in this order:

  • ./config.yaml
  • ./config.yml
  • ./config.json
  • /etc/elasticview/config.yaml

Basic Configuration

Create a config.yaml file:

yaml
# Server Configuration
server:
  port: 8080
  host: "0.0.0.0"
  mode: "release"  # debug, release, test
  
# Database Configuration
database:
  host: "localhost"
  port: 3306
  name: "elasticview"
  user: "root"
  password: "password"
  charset: "utf8mb4"
  max_idle_conns: 10
  max_open_conns: 100
  
# Elasticsearch Configuration
elasticsearch:
  hosts:
    - "http://localhost:9200"
  username: ""
  password: ""
  timeout: 30s
  
# Security Configuration
security:
  jwt_secret: "your-secret-key"
  session_timeout: "24h"
  password_salt: "your-salt"
  
# Plugin Configuration
plugins:
  enabled: true
  directory: "./plugins"
  auto_update: false
  
# Logging Configuration
logging:
  level: "info"  # debug, info, warn, error
  file: "./logs/elasticview.log"
  max_size: 100  # MB
  max_age: 30    # days
  max_backups: 10

Environment Variables

All configuration options can be set using environment variables with the EV_ prefix:

Server Configuration

bash
export EV_SERVER_PORT=8080
export EV_SERVER_HOST="0.0.0.0"
export EV_SERVER_MODE="release"

Database Configuration

bash
export EV_DATABASE_HOST="localhost"
export EV_DATABASE_PORT=3306
export EV_DATABASE_NAME="elasticview"
export EV_DATABASE_USER="root"
export EV_DATABASE_PASSWORD="password"

Elasticsearch Configuration

bash
export EV_ELASTICSEARCH_HOSTS="http://localhost:9200,http://localhost:9201"
export EV_ELASTICSEARCH_USERNAME="elastic"
export EV_ELASTICSEARCH_PASSWORD="password"

Security Configuration

bash
export EV_SECURITY_JWT_SECRET="your-secret-key"
export EV_SECURITY_SESSION_TIMEOUT="24h"
export EV_SECURITY_PASSWORD_SALT="your-salt"

Advanced Configuration

SSL/TLS Configuration

yaml
server:
  ssl:
    enabled: true
    cert_file: "/path/to/cert.pem"
    key_file: "/path/to/key.pem"
    port: 443

CORS Configuration

yaml
server:
  cors:
    enabled: true
    allowed_origins:
      - "http://localhost:3000"
      - "https://yourdomain.com"
    allowed_methods:
      - "GET"
      - "POST"
      - "PUT"
      - "DELETE"
    allowed_headers:
      - "Content-Type"
      - "Authorization"

Rate Limiting

yaml
server:
  rate_limit:
    enabled: true
    requests_per_minute: 100
    burst: 200

Plugin Configuration

yaml
plugins:
  enabled: true
  directory: "./plugins"
  auto_update: false
  allowed_origins:
    - "https://plugins.elasticview.com"
  security:
    verify_signatures: true
    max_size: "100MB"

Cache Configuration

yaml
cache:
  enabled: true
  type: "redis"  # memory, redis
  redis:
    host: "localhost"
    port: 6379
    password: ""
    db: 0
  ttl: "1h"

Database Configuration

MySQL Configuration

yaml
database:
  type: "mysql"
  host: "localhost"
  port: 3306
  name: "elasticview"
  user: "elasticview_user"
  password: "secure_password"
  charset: "utf8mb4"
  timezone: "UTC"
  max_idle_conns: 10
  max_open_conns: 100
  conn_max_lifetime: "1h"

PostgreSQL Configuration

yaml
database:
  type: "postgres"
  host: "localhost"
  port: 5432
  name: "elasticview"
  user: "elasticview_user"
  password: "secure_password"
  sslmode: "disable"
  timezone: "UTC"

SQLite Configuration

yaml
database:
  type: "sqlite"
  path: "./data/elasticview.db"

Monitoring Configuration

Metrics

yaml
monitoring:
  metrics:
    enabled: true
    path: "/metrics"
    port: 9090
    
  health_check:
    enabled: true
    path: "/health"
    
  profiling:
    enabled: false
    path: "/debug/pprof"

Logging

yaml
logging:
  level: "info"
  format: "json"  # text, json
  output: "file"  # stdout, file, both
  file:
    path: "./logs/elasticview.log"
    max_size: 100    # MB
    max_age: 30      # days
    max_backups: 10
    compress: true

Security Best Practices

JWT Configuration

yaml
security:
  jwt:
    secret: "your-very-long-secret-key-at-least-32-chars"
    issuer: "elasticview"
    expiration: "24h"
    refresh_expiration: "7d"

Password Policy

yaml
security:
  password:
    min_length: 8
    require_uppercase: true
    require_lowercase: true
    require_numbers: true
    require_symbols: true
    salt: "your-unique-salt"

Session Configuration

yaml
security:
  session:
    timeout: "24h"
    secure: true
    http_only: true
    same_site: "strict"

Docker Configuration

Environment File

Create a .env file for Docker:

bash
# Server
EV_SERVER_PORT=8080
EV_SERVER_HOST=0.0.0.0

# Database
EV_DATABASE_HOST=mysql
EV_DATABASE_PORT=3306
EV_DATABASE_NAME=elasticview
EV_DATABASE_USER=root
EV_DATABASE_PASSWORD=password

# Elasticsearch
EV_ELASTICSEARCH_HOSTS=http://elasticsearch:9200

# Security
EV_SECURITY_JWT_SECRET=your-secret-key

Configuration Validation

ElasticView validates configuration on startup. Check logs for validation errors:

bash
# Check configuration
./elasticview --config-check

# Validate specific config file
./elasticview --config ./custom-config.yaml --config-check

Troubleshooting

Common Issues

Database Connection

yaml
# Add connection timeout
database:
  timeout: "30s"
  read_timeout: "30s"
  write_timeout: "30s"

Memory Issues

yaml
# Limit memory usage
server:
  max_memory: "512MB"
  gc_percent: 100

Performance Tuning

yaml
# Optimize for performance
server:
  read_timeout: "30s"
  write_timeout: "30s"
  idle_timeout: "120s"
  max_header_bytes: 1048576

Next Steps