Class: Fluent::SNSOutput

Inherits:
Output
  • Object
show all
Includes:
SetTagKeyMixin, SetTimeKeyMixin
Defined in:
lib/fluent/plugin/out_sns.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



24
25
26
# File 'lib/fluent/plugin/out_sns.rb', line 24

def configure(conf)
    super
end

#emit(tag, es, chain) ⇒ Object



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

def emit(tag, es, chain)
    chain.next
    es.each {|time,record|
        record["time"] = Time.at(time).localtime
        subject = record[@sns_subject_key] || @sns_subject  || 'Fluent-Notification'
        @topic.publish(record.to_json, :subject => subject )
    }
end

#get_topicObject



56
57
58
59
60
61
62
# File 'lib/fluent/plugin/out_sns.rb', line 56

def get_topic()
    @sns.topics.each do |topic|
        if @sns_topic_name == topic.name
            return topic
        end
    end
end

#shutdownObject



43
44
45
# File 'lib/fluent/plugin/out_sns.rb', line 43

def shutdown
    super
end

#startObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fluent/plugin/out_sns.rb', line 28

def start
    super
    options = {}
    options[:sns_endpoint] = @sns_endpoint
    options[:proxy_uri] = @proxy
    if @aws_key_id && @aws_sec_key
      options[:access_key_id] = @aws_key_id
      options[:secret_access_key] = @aws_sec_key
    end
    AWS.config(options)
    
    @sns = AWS::SNS.new
    @topic = get_topic
end