Class: LogStash::Inputs::Faker
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Faker
- Defined in:
- lib/logstash/inputs/faker.rb
Overview
- NOTE
-
The values put into the add_faker_field params must be available modules and method calls from the Faker gem library seen at github.com/stympy/faker/
Example:
- source, ruby
-
input {
faker { count => 1 add_faker_field => { "[name][last_name]" => "Name.last_name" "[name][first_name]" => "Name.first_name" "[address][city]" => "Address.city" "[address][address1]" => "Address.street_address" } overwrite_fields => true }
}
Instance Method Summary collapse
Instance Method Details
#close ⇒ Object
211 212 213 214 215 216 217 218 219 |
# File 'lib/logstash/inputs/faker.rb', line 211 def close if @codec.respond_to?(:flush) @codec.flush do |event| decorate(event) event.set("host", @host) queue << event end end end |
#register ⇒ Object
87 88 89 90 |
# File 'lib/logstash/inputs/faker.rb', line 87 def register @host = Socket.gethostname @count = Array(@count).first end |
#run(queue) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/logstash/inputs/faker.rb', line 92 def run(queue) number = 0 set_primary_key if @add_primary_key_to_events set_foreign_keys if @add_foreign_keys_to_events while !stop? && (@count <= 0 || number < @count) event = LogStash::Event.new({}) add_faker_fields(event) if @splitable_field add_splitable_fields(event) end if @add_primary_key_to_events LogStash::Util::Decorators.add_fields(@primary_key, event,"inputs/#{self.class.name}") end decorate(event) event.set("host", @host) queue << event number += 1 end #end loop end |