Class: LogStash::Outputs::Logentries

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/logentries.rb

Instance Method Summary collapse

Instance Method Details

#receive(event) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/logstash/outputs/logentries.rb', line 29

def receive(event)
    return unless output?(event)
    
    if event == LogStash::SHUTDOWN
        finished
        return
    end
    
    # Send the event using token
    url = URI.parse("https://js.logentries.com/v1/logs/#{event.sprintf(@token)}")
    
    # Debug the URL here
    @logger.info("Sending using #{event.sprintf(@token)} Logentries Token")
    
    # Open HTTP connection
    http = Net::HTTP.new(url.host, url.port)
    
    # Use secure SSL
    if url.scheme == 'https'
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end
    
    request = Net::HTTP::Post.new(url.path)
    
    #Prepend the message body with "event" to allow the js.logentries to pick it up
    request.body = "{\"event\":" + event.to_json + "}"
    response = http.request(request)
    
    if response.is_a?(Net::HTTPSuccess)
        @logger.info("Event Sent!")
        else
        @logger.warn("HTTP error", :error => response.error!)
    end
    
end

#registerObject



26
27
# File 'lib/logstash/outputs/logentries.rb', line 26

def register
end