Sha256: 0b3d95c0f8ece7c4d1a5ebea9616373fa505f2654a6347960616d6976d2f8f33

Contents?: true

Size: 633 Bytes

Versions: 19

Compression:

Stored size: 633 Bytes

Contents

module Rearview
  class GraphiteParser
    ## returns an array of arrays of pairs with 2 elements timestamp and value (may be nil)
    def self.parse(lines)
      lines.strip.split("\n").map do |line|
        metric, startTime, endTime, interval, dataStr = /(.*),(\d+),(\d+),(\d+)\|(.*)/.match(line)[1..-1]
        data = dataStr.split(",")

        0.upto(data.length - 1).map do |i|
          value = data[i]
          {
            :metric    => metric,
            :timestamp => startTime.to_i + (interval.to_i * i),
            :value     => !value.nil?  ? value.to_f : value
          }
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rearview-1.1.2-jruby lib/rearview/graphite_parser.rb
rearview-1.1.1-jruby lib/rearview/graphite_parser.rb
rearview-1.1.0-jruby lib/rearview/graphite_parser.rb
rearview-1.0.3.rc.4-jruby lib/rearview/graphite_parser.rb
rearview-1.0.3.rc.3-jruby lib/rearview/graphite_parser.rb
rearview-1.0.3.rc.2-jruby lib/rearview/graphite_parser.rb
rearview-1.0.3.rc.1-jruby lib/rearview/graphite_parser.rb
rearview-1.0.2-jruby lib/rearview/graphite_parser.rb
rearview-1.0.2.rc.4-jruby lib/rearview/graphite_parser.rb
rearview-1.0.2.rc.3-jruby lib/rearview/graphite_parser.rb
rearview-1.0.2.rc.2-jruby lib/rearview/graphite_parser.rb
rearview-1.0.2.rc.1-jruby lib/rearview/graphite_parser.rb
rearview-1.0.1-jruby lib/rearview/graphite_parser.rb
rearview-1.0.0-jruby lib/rearview/graphite_parser.rb
rearview-1.0.0.rc5-jruby lib/rearview/graphite_parser.rb
rearview-1.0.0.rc4-jruby lib/rearview/graphite_parser.rb
rearview-1.0.0.rc3-jruby lib/rearview/graphite_parser.rb
rearview-1.0.0.rc2-jruby lib/rearview/graphite_parser.rb
rearview-1.0.0.rc1-jruby lib/rearview/graphite_parser.rb