Class: Fluent::Plugin::TeamsOutput

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

Instance Method Summary collapse

Constructor Details

#initializeTeamsOutput

Returns a new instance of TeamsOutput.



15
16
17
# File 'lib/fluent/plugin/out_teams.rb', line 15

def initialize
  super
end

Instance Method Details

#build_payload(args = {}) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/fluent/plugin/out_teams.rb', line 61

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



19
20
21
# File 'lib/fluent/plugin/out_teams.rb', line 19

def configure(conf)
  super
end

#format(tag, time, record) ⇒ Object



31
32
33
# File 'lib/fluent/plugin/out_teams.rb', line 31

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

#formatted_to_msgpack_binary?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fluent/plugin/out_teams.rb', line 35

def formatted_to_msgpack_binary?
  true
end

#post_message(args = {}) ⇒ Object



56
57
58
59
# File 'lib/fluent/plugin/out_teams.rb', line 56

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

#prefer_buffered_processingObject



39
40
41
# File 'lib/fluent/plugin/out_teams.rb', line 39

def prefer_buffered_processing
  false
end

#process(tag, es) ⇒ Object



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

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

#shutdownObject



27
28
29
# File 'lib/fluent/plugin/out_teams.rb', line 27

def shutdown
  super
end

#startObject



23
24
25
# File 'lib/fluent/plugin/out_teams.rb', line 23

def start
  super
end

#write(chunk) ⇒ Object



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

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