Class: MonogotoApi::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/monogoto_api/event.rb,
lib/monogoto_api/event/list.rb

Defined Under Namespace

Classes: List

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_typeObject (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

#msgObject (readonly)

Returns the value of attribute msg.



5
6
7
# File 'lib/monogoto_api/event.rb', line 5

def msg
  @msg
end

#msg_typeObject (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

#severityObject (readonly)

Returns the value of attribute severity.



5
6
7
# File 'lib/monogoto_api/event.rb', line 5

def severity
  @severity
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/monogoto_api/event.rb', line 5

def timestamp
  @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