Class: Graylog2Client::Parser
- Inherits:
-
Object
- Object
- Graylog2Client::Parser
- Defined in:
- lib/graylog2-client/parser.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(options) ⇒ Parser
constructor
A new instance of Parser.
- #messages_for(pattern) ⇒ Object
Constructor Details
#initialize(options) ⇒ Parser
Returns a new instance of Parser.
9 10 11 |
# File 'lib/graylog2-client/parser.rb', line 9 def initialize() self.url = [:url] end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/graylog2-client/parser.rb', line 7 def url @url end |
Instance Method Details
#messages_for(pattern) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/graylog2-client/parser.rb', line 13 def (pattern) params = JSON.dump({ :from => 0, :size => 1000, :query => { :query_string => { :query => pattern, :default_operator => "AND" } } }) response = HTTParty.get(url, :body => params) hits = response["hits"]["hits"] hits.sort_by! {|m| m["_source"]["created_at"]} hits.map {|m| m["_source"]["message"]} end |