class

Logarithm::Config

Inherits YAML::Serializable < Reference < Object

Configuration management for Logarithm.

This class handles all configuration settings for the anomaly detection system, supporting YAML configuration files, environment variables, and programmatic configuration. It provides sensible defaults and validation.

Configuration Sources (in precedence order)

  1. Command-line flags (highest priority)
  2. Environment variables
  3. YAML configuration file
  4. Built-in defaults (lowest priority)

Configuration File Format

# /etc/logarithm/config.yaml or ~/.config/logarithm/config.yaml
data_dir: ~/.local/share/logarithm
threshold: 0.85
duration: 48h
vocab_size: 1000
batch_size: 10000
max_batches: 5

Environment Variables

  • LOGARITHM_DATA_DIR: Model and data storage directory
  • LOGARITHM_THRESHOLD: Anomaly detection sensitivity (0.0-1.0)
  • LOGARITHM_VOCAB_SIZE: TF-IDF vocabulary size
  • LOGARITHM_BATCH_SIZE: Training batch size
  • LOGARITHM_MAX_BATCHES: Maximum training batches

Example Usage

# Load from file
config = Config.load("config.yaml")

# Create with defaults
config = Config.new

# Override specific settings
config = Config.new(
  threshold: 0.9,
  vocab_size: 2000
)

# Use in pipeline
pipeline = Pipeline.new(source, vectorizer, model, config)

Constructors

load(path : String) : Config
Source
new(data_dir : String = PathResolver.data_dir, threshold : Float64 = 0.85, duration : String = "48h", vocab_size : Int32 = 100, batch_size : Int32 = 10000, max_batches : Int32 = 5)

Creates a new configuration with specified or default values.

Uses PathResolver for smart default data directory detection.

Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Class methods

default_config_path
Source

Instance methods

batch_size

Number of log entries to process in each training batch. Larger batches may improve training stability but use more memory.

Source
batch_size=(batch_size : Int32)

Number of log entries to process in each training batch. Larger batches may improve training stability but use more memory.

Source
data_dir

Directory for storing trained models, logs, and temporary files. Defaults to XDG data directory (~/.local/share/logarithm).

Source
data_dir=(data_dir : String)

Directory for storing trained models, logs, and temporary files. Defaults to XDG data directory (~/.local/share/logarithm).

Source
duration

Default training duration when not specified via CLI. Format: "30s", "5m", "2h", "1d" (seconds, minutes, hours, days).

Source
duration=(duration : String)

Default training duration when not specified via CLI. Format: "30s", "5m", "2h", "1d" (seconds, minutes, hours, days).

Source
max_batches

Maximum number of training batches to process. Limits training time and prevents overfitting on repetitive logs.

Source
max_batches=(max_batches : Int32)

Maximum number of training batches to process. Limits training time and prevents overfitting on repetitive logs.

Source
threshold

Anomaly detection threshold (0.0 to 1.0).

Lower values increase sensitivity (more false positives). Higher values decrease sensitivity (more false negatives). Typical range: 0.7-0.95 depending on log noise levels.

Source
threshold=(threshold : Float64)

Anomaly detection threshold (0.0 to 1.0).

Lower values increase sensitivity (more false positives). Higher values decrease sensitivity (more false negatives). Typical range: 0.7-0.95 depending on log noise levels.

Source
vocab_size

Maximum size of TF-IDF vocabulary. Larger vocabularies capture more terms but increase memory usage. Typical range: 100-5000 depending on log complexity.

Source
vocab_size=(vocab_size : Int32)

Maximum size of TF-IDF vocabulary. Larger vocabularies capture more terms but increase memory usage. Typical range: 100-5000 depending on log complexity.

Source