Class: MonogotoApi::Event
- Inherits:
-
Object
- Object
- MonogotoApi::Event
- Defined in:
- lib/monogoto_api/event.rb,
lib/monogoto_api/event/list.rb
Defined Under Namespace
Classes: List
Instance Attribute Summary collapse
-
#data_type ⇒ Object
readonly
Returns the value of attribute data_type.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#msg_type ⇒ Object
readonly
Returns the value of attribute msg_type.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(**attributes) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 12 13 |
# File 'lib/monogoto_api/event.rb', line 7 def initialize(**attributes) @severity = attributes[:severity] @msg = attributes[:msg] @msg_type = attributes[:msg_type] @timestamp = attributes[:timestamp] @data_type = attributes[:data_type] end |
Instance Attribute Details
#data_type ⇒ Object (readonly)
Returns the value of attribute data_type.
5 6 7 |
# File 'lib/monogoto_api/event.rb', line 5 def data_type @data_type end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
5 6 7 |
# File 'lib/monogoto_api/event.rb', line 5 def msg @msg end |
#msg_type ⇒ Object (readonly)
Returns the value of attribute msg_type.
5 6 7 |
# File 'lib/monogoto_api/event.rb', line 5 def msg_type @msg_type end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
5 6 7 |
# File 'lib/monogoto_api/event.rb', line 5 def severity @severity end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/monogoto_api/event.rb', line 5 def @timestamp end |
Class Method Details
.parse(hash_event) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/monogoto_api/event.rb', line 15 def self.parse(hash_event) data_first = hash_event["_source"] new( severity: data_first["Severity"], msg: data_first["message"], msg_type: data_first["MessageType"], timestamp: Time.at(data_first["Timestamp"] / 1_000), data_type: data_first["EsDataType"] ) end |
.parse_many(hits) ⇒ Object
26 27 28 29 30 |
# File 'lib/monogoto_api/event.rb', line 26 def self.parse_many(hits) output = [] hits.each { |pre_event| output.push(parse(pre_event)) } output end |