module MetricsCapacitor::Config

Attributes

_cfg[R]

Public Instance Methods

load!() click to toggle source
# File lib/metrics-capacitor/config.rb, line 15
def load!
  @_cfg = {
    syslog: false,
    debug: false,
    redis: {
      url: 'redis://127.0.0.1:6379/0',
      timeout: 5,
    },
    elasticsearch: {
      urls: ['http://localhost:9200/'],
      index: 'metrics',
      timeout: 10,
      connections: 2,
    },
    scrubber: {
      threads: 4,
      processes: 2,
      retry: 3,
      tags: {}
    },
    writer: {
      processes: 2,
      doc_type: 'actual',
      bulk_max: 5000,
      bulk_wait: 10,
      ttl: '1w'
    },
    aggregator: {
      doc_type: 'aggregated',
      aggregate_by: 600, # seconds
      optimize_indices: true,
    }
  }
  @_cfg = @_cfg.deep_merge YAML.load_file('/etc/metrics-capacitor.yaml') if File.exists? '/etc/metrics-capacitor.yaml'
end
method_missing(name, *args, &block) click to toggle source
# File lib/metrics-capacitor/config.rb, line 51
def method_missing (name, *args, &block)
  return @_cfg[name.to_sym] if @_cfg[name.to_sym] != nil
  fail(NoMethodError, "Unknown configuration section Config.#{name}", caller)
rescue NoMethodError => e
  $stderr.puts "ERROR config: #{e.class}: #{e.message}"
  $stderr.puts e.backtrace.map { |l| "ERROR config: #{l}\n" }.join
  exit! 1
end