Class: LogStash::Inputs::CloudflareLogs
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::CloudflareLogs
- Defined in:
- lib/logstash/inputs/cloudflare_logs.rb
Instance Method Summary collapse
-
#cloudflare_access ⇒ Object
def register.
- #process_logs(queue) ⇒ Object
- #register ⇒ Object
- #run(queue) ⇒ Object
-
#stop ⇒ Object
def run.
Instance Method Details
#cloudflare_access ⇒ Object
def register
80 81 82 83 84 85 86 |
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 80 def cloudflare_access @access ||= CloudflareAccess.new(auth_key: @auth_key, auth_email: @auth_email, domain: @domain_key, logger: @logger, metadata_file: @metadata_file) end |
#process_logs(queue) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 88 def process_logs(queue) cloudflare_access.logs.each do |log| log['fields.type'] = 'cloudflare' log['fields.env'] = @environment_name event = LogStash::Event.new(log) event.= LogStash::Timestamp.at(log['EdgeStartTimestamp'].to_i/1_000_000_000) decorate(event) queue << event end cloudflare_access.('start_time', cloudflare_access.end_time) end |
#register ⇒ Object
76 77 78 |
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 76 def register @host = Socket.gethostname end |
#run(queue) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 101 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 |
#stop ⇒ Object
def run
114 115 116 117 118 119 120 |
# File 'lib/logstash/inputs/cloudflare_logs.rb', line 114 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 |