Class: Fluent::Plugin::TeamsOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_teams.rb

Constant Summary collapse

DEFAULT_BUFFER_TYPE =
'memory'.freeze

Instance Method Summary collapse

Constructor Details

#initializeTeamsOutput

Returns a new instance of TeamsOutput.



25
26
27
# File 'lib/fluent/plugin/out_teams.rb', line 25

def initialize
  super
end

Instance Method Details

#build_payload(args = {}) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/fluent/plugin/out_teams.rb', line 71

def build_payload(args = {})
  tag = args[:tag]
  time = args[:time]
  record = args[:record]

  text = ERB.new(@text).result(binding).gsub('\\n', "\n")
  { text: text }
end

#configure(conf) ⇒ Object



29
30
31
# File 'lib/fluent/plugin/out_teams.rb', line 29

def configure(conf)
  super
end

#format(tag, time, record) ⇒ Object



41
42
43
# File 'lib/fluent/plugin/out_teams.rb', line 41

def format(tag, time, record)
  [time, record].to_msgpack
end

#formatted_to_msgpack_binary?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/fluent/plugin/out_teams.rb', line 45

def formatted_to_msgpack_binary?
  true
end

#post_message(args = {}) ⇒ Object



66
67
68
69
# File 'lib/fluent/plugin/out_teams.rb', line 66

def post_message(args = {})
  payload = build_payload(args)
  RestClient.post(@webhook_url, payload.to_json, content_type: :json)
end

#prefer_buffered_processingObject



49
50
51
# File 'lib/fluent/plugin/out_teams.rb', line 49

def prefer_buffered_processing
  @buffered
end

#process(tag, es) ⇒ Object



53
54
55
56
57
# File 'lib/fluent/plugin/out_teams.rb', line 53

def process(tag, es)
  es.each do |time, record|
    post_message(tag: tag, time: time, record: record)
  end
end

#shutdownObject



37
38
39
# File 'lib/fluent/plugin/out_teams.rb', line 37

def shutdown
  super
end

#startObject



33
34
35
# File 'lib/fluent/plugin/out_teams.rb', line 33

def start
  super
end

#write(chunk) ⇒ Object



59
60
61
62
63
64
# File 'lib/fluent/plugin/out_teams.rb', line 59

def write(chunk)
  tag = chunk..tag
  chunk.msgpack_each do |time, record|
    post_message(tag: tag, time: time, record: record)
  end
end