Class: Loki::Entry
- Inherits:
-
Object
- Object
- Loki::Entry
- Includes:
- Loki
- Defined in:
- lib/logstash/outputs/loki/entry.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
Instance Method Summary collapse
-
#initialize(event, message_field, include_fields, metadata_fields) ⇒ Entry
constructor
A new instance of Entry.
Methods included from Loki
Constructor Details
#initialize(event, message_field, include_fields, metadata_fields) ⇒ Entry
Returns a new instance of Entry.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/logstash/outputs/loki/entry.rb', line 8 def initialize(event,,include_fields,) @entry = { "ts" => to_ns(event.get("@timestamp")), "line" => event.get().to_s } event = event.clone() event.remove() event.remove("@timestamp") @labels = {} event.to_hash.each { |key,value| next if key.start_with?('@') next if value.is_a?(Hash) next if include_fields.length() > 0 and not include_fields.include?(key) @labels[key] = value.to_s } # Unlike include_fields we should skip if no metadata_fields provided if .length() > 0 @metadata = {} event.to_hash.each { |key,value| next if key.start_with?('@') next if value.is_a?(Hash) next if .length() > 0 and not .include?(key) @metadata[key] = value.to_s } # Add @metadata to @entry if there was a match if @metadata.size > 0 @entry.merge!('metadata' => @metadata) end end end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
7 8 9 |
# File 'lib/logstash/outputs/loki/entry.rb', line 7 def entry @entry end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
7 8 9 |
# File 'lib/logstash/outputs/loki/entry.rb', line 7 def labels @labels end |