class Fluent::StatsitePlugin::MetricFormat
This represent a key/value format of Metric
Constants
- CONSTANT_VALUE
- ELEMENT
- PATTERN
- SUBSTITUTE
- SUBSTITUTE_REGEXP
Public Class Methods
new(str)
click to toggle source
# File lib/fluent/plugin/statsite/metric_format.rb, line 11 def initialize(str) @str = str @no_substitute = str.index('$').nil? end
validate(str)
click to toggle source
# File lib/fluent/plugin/statsite/metric_format.rb, line 28 def self.validate(str) if /^#{PATTERN}$/.match(str).nil? raise ConfigError, "invalid format of key/value field, it must be #{PATTERN}, but specified as #{str}" end new(str) end
Public Instance Methods
convert(record)
click to toggle source
# File lib/fluent/plugin/statsite/metric_format.rb, line 16 def convert(record) if @no_substitute @str else @str.gsub(SUBSTITUTE_REGEXP) { record.fetch($1) } rescue nil end end
to_s()
click to toggle source
# File lib/fluent/plugin/statsite/metric_format.rb, line 24 def to_s @str end