added working config lib
This commit is contained in:
parent
f8576c0d93
commit
def9bce8dc
33 changed files with 2896 additions and 1485 deletions
61
libs/config/src/loki.ts
Normal file
61
libs/config/src/loki.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* Loki log aggregation configuration using envalid
|
||||
* Centralized logging configuration for the Stock Bot platform
|
||||
*/
|
||||
import { cleanEnv, str, port, bool, num } from 'envalid';
|
||||
|
||||
/**
|
||||
* Loki configuration with validation and defaults
|
||||
*/
|
||||
export const lokiConfig = cleanEnv(process.env, {
|
||||
// Loki Server
|
||||
LOKI_HOST: str({ default: 'localhost', desc: 'Loki host' }),
|
||||
LOKI_PORT: port({ default: 3100, desc: 'Loki port' }),
|
||||
LOKI_URL: str({ default: '', desc: 'Complete Loki URL (overrides host/port)' }),
|
||||
|
||||
// Authentication
|
||||
LOKI_USERNAME: str({ default: '', desc: 'Loki username (if auth enabled)' }),
|
||||
LOKI_PASSWORD: str({ default: '', desc: 'Loki password (if auth enabled)' }),
|
||||
LOKI_TENANT_ID: str({ default: '', desc: 'Loki tenant ID (for multi-tenancy)' }),
|
||||
|
||||
// Push Configuration
|
||||
LOKI_PUSH_TIMEOUT: num({ default: 10000, desc: 'Push timeout in ms' }),
|
||||
LOKI_BATCH_SIZE: num({ default: 1024, desc: 'Batch size for log entries' }),
|
||||
LOKI_BATCH_WAIT: num({ default: 1000, desc: 'Batch wait time in ms' }),
|
||||
|
||||
// Retention Settings
|
||||
LOKI_RETENTION_PERIOD: str({ default: '30d', desc: 'Log retention period' }),
|
||||
LOKI_MAX_CHUNK_AGE: str({ default: '1h', desc: 'Maximum chunk age' }),
|
||||
|
||||
// TLS Settings
|
||||
LOKI_TLS_ENABLED: bool({ default: false, desc: 'Enable TLS for Loki' }),
|
||||
LOKI_TLS_INSECURE: bool({ default: false, desc: 'Skip TLS verification' }),
|
||||
|
||||
// Log Labels
|
||||
LOKI_DEFAULT_LABELS: str({ default: '', desc: 'Default labels for all log entries (JSON format)' }),
|
||||
LOKI_SERVICE_LABEL: str({ default: 'stock-bot', desc: 'Service label for log entries' }),
|
||||
LOKI_ENVIRONMENT_LABEL: str({ default: 'development', desc: 'Environment label for log entries' }),
|
||||
});
|
||||
|
||||
// Export typed configuration object
|
||||
export type LokiConfig = typeof lokiConfig;
|
||||
|
||||
// Export individual config values for convenience
|
||||
export const {
|
||||
LOKI_HOST,
|
||||
LOKI_PORT,
|
||||
LOKI_URL,
|
||||
LOKI_USERNAME,
|
||||
LOKI_PASSWORD,
|
||||
LOKI_TENANT_ID,
|
||||
LOKI_PUSH_TIMEOUT,
|
||||
LOKI_BATCH_SIZE,
|
||||
LOKI_BATCH_WAIT,
|
||||
LOKI_RETENTION_PERIOD,
|
||||
LOKI_MAX_CHUNK_AGE,
|
||||
LOKI_TLS_ENABLED,
|
||||
LOKI_TLS_INSECURE,
|
||||
LOKI_DEFAULT_LABELS,
|
||||
LOKI_SERVICE_LABEL,
|
||||
LOKI_ENVIRONMENT_LABEL,
|
||||
} = lokiConfig;
|
||||
Loading…
Add table
Add a link
Reference in a new issue