Class: Fluent::CloudwatchInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_cloudwatch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCloudwatchInput

Returns a new instance of CloudwatchInput.



40
41
42
# File 'lib/fluent/plugin/in_cloudwatch.rb', line 40

def initialize
  super
end

Instance Attribute Details

#dimensionsObject

Returns the value of attribute dimensions.



38
39
40
# File 'lib/fluent/plugin/in_cloudwatch.rb', line 38

def dimensions
  @dimensions
end

Instance Method Details

#configure(conf) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fluent/plugin/in_cloudwatch.rb', line 44

def configure(conf)
  super

  @dimensions = []
  if @dimensions_name && @dimensions_value
    names = @dimensions_name.split(",").each
    values = @dimensions_value.split(",").each
    loop do
      @dimensions.push({
        :name => names.next,
        :value => values.next,
      })
    end
  elsif @dimensions_name || @dimensions_value
    @dimensions.push({
      :name => @dimensions_name,
      :value => @dimensions_value,
    })
  end

  endpoint = URI(@cw_endpoint)
  if endpoint.scheme != "http" && endpoint.scheme != "https"
    @cw_endpoint_uri = "https://#{@cw_endpoint}"
  else
    @cw_endpoint_uri = endpoint.to_s
  end

  if !@region
    @region = @cw_endpoint.split('.')[1]
  end
end

#shutdownObject



86
87
88
89
90
91
92
93
# File 'lib/fluent/plugin/in_cloudwatch.rb', line 86

def shutdown
  super
  @running = false
  @watcher.terminate
  @monitor.terminate
  @watcher.join
  @monitor.join
end

#startObject



76
77
78
79
80
81
82
83
84
# File 'lib/fluent/plugin/in_cloudwatch.rb', line 76

def start
  super

  @running = true
  @updated = Time.now
  @watcher = Thread.new(&method(:watch))
  @monitor = Thread.new(&method(:monitor))
  @mutex   = Mutex.new
end