Class: LogStash::Inputs::CloudflareLogs

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/cloudflare_logs.rb

Instance Method Summary collapse

Instance Method Details

#cloudflare_accessObject

def register



74
75
76
77
78
79
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 74

def cloudflare_access
  CloudflareAccess.new(auth_key: @auth_key,
                       auth_email: @auth_email,
                       domain: @domain_key,
                       metadata_file: @metadata_file)
end

#process_logs(queue) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 81

def process_logs(queue)
  cloudflare_access.logs.each do |log|
    event = LogStash::Event.new(log)
    decorate(event)
    queue << event
  end
end

#registerObject



70
71
72
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 70

def register
  @host = Socket.gethostname
end

#run(queue) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 89

def run(queue)
  # we can abort the loop if stop? becomes true
  until stop?
    process_logs(queue)

    # because the sleep interval can be big, when shutdown happens
    # we want to be able to abort the sleep
    # Stud.stoppable_sleep will frequently evaluate the given block
    # and abort the sleep(@interval) if the return value is true
    Stud.stoppable_sleep(@interval) { stop? }
  end # loop
end

#stopObject

def run



102
103
104
105
106
107
108
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 102

def stop
  # nothing to do in this case so it is not necessary to define stop
  # examples of common 'stop' tasks:
  #  * close sockets (unblocking blocking reads/accepts)
  #  * cleanup temporary files
  #  * terminate spawned threads
end