63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
/**
|
|
* Loki log aggregation configuration using Yup
|
|
* Centralized logging configuration for the Stock Bot platform
|
|
*/
|
|
import { cleanEnv, envValidators } from './env-utils';
|
|
|
|
const { str, port, bool, num } = envValidators;
|
|
|
|
/**
|
|
* Loki configuration with validation and defaults
|
|
*/
|
|
export const lokiConfig = cleanEnv(process.env, {
|
|
// Loki Server
|
|
LOKI_HOST: str('localhost', 'Loki host'),
|
|
LOKI_PORT: port(3100, 'Loki port'),
|
|
LOKI_URL: str('', 'Complete Loki URL (overrides host/port)'),
|
|
|
|
// Authentication
|
|
LOKI_USERNAME: str('', 'Loki username (if auth enabled)'),
|
|
LOKI_PASSWORD: str('', 'Loki password (if auth enabled)'),
|
|
LOKI_TENANT_ID: str('', 'Loki tenant ID (for multi-tenancy)'),
|
|
|
|
// Push Configuration
|
|
LOKI_PUSH_TIMEOUT: num(10000, 'Push timeout in ms'),
|
|
LOKI_BATCH_SIZE: num(1024, 'Batch size for log entries'),
|
|
LOKI_BATCH_WAIT: num(5, 'Batch wait time in ms'),
|
|
|
|
// Retention Settings
|
|
LOKI_RETENTION_PERIOD: str('30d', 'Log retention period'),
|
|
LOKI_MAX_CHUNK_AGE: str('1h', 'Maximum chunk age'),
|
|
|
|
// TLS Settings
|
|
LOKI_TLS_ENABLED: bool(false, 'Enable TLS for Loki'),
|
|
LOKI_TLS_INSECURE: bool(false, 'Skip TLS verification'),
|
|
|
|
// Log Labels
|
|
LOKI_DEFAULT_LABELS: str('', 'Default labels for all log entries (JSON format)'),
|
|
LOKI_SERVICE_LABEL: str('stock-bot', 'Service label for log entries'),
|
|
LOKI_ENVIRONMENT_LABEL: str('development', '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;
|