Sha256: f134ae456fe12e2cec5cbb8be62c0e4812fd2665880fe4d9ae11a912061be4ac

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
require "logstash/codecs/base"
require "logstash/codecs/line"
require "influxparser"
# Add any asciidoc formatted documentation here
class LogStash::Codecs::Influxdb < LogStash::Codecs::Base

  # input {
  #   stdin { codec => influxdb { } }
  # }
  #
  # or
  #
  # output {
  #   stdout { codec => influxdb { } }
  # }
  config_name "influxdb"

  # Append a string to the message
  config :append, :validate => :string, :default => ', Hello World!'

  public
  def register
    @lines = LogStash::Codecs::Line.new
    @lines.charset = "UTF-8"
  end

  public
  def decode(data)
    @lines.decode(data) do |line|
      # replace = { "message" => line.get("message").to_s + @append }
      # yield LogStash::Event.new(replace)
      yield LogStash::Event.new(InfluxParser.parse_point(line.get("message")))
    end
  end # def decode

  public
  def encode(event)
    # @on_event.call(event, event.get("message").to_s + @append + NL)
    # there is no encode (maybe some day)
    yield event
  end # def encode

end # class LogStash::Codecs::Influxdb

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-codec-influxdb-0.1.0 lib/logstash/codecs/influxdb.rb