1

Is there any inbuilt way to generate random text (of certain length) or number (of certain range) in logstash input/filer plugins? or should we write one in ruby.

user3366706
  • 1,529
  • 3
  • 31
  • 54

1 Answers1

4

Sounds like the generator input could work for you.

For more variety in your messages, ruby:

filter {
    ruby {
        code => "
          begin

            # random 10-letter string
            # event['message'] = rand(36**10).to_s(36)

            # random integer
            event['message'] = rand(100).to_s()

          rescue Exception => e
            event['ruby_exception'] = 'EEK: ' + e.message
          end
        "
    }
}
Alain Collins
  • 16,268
  • 2
  • 32
  • 55
  • no, its not. "generator input" actually needs set of lines and number of times those lines have to be generated as input events. thats not what i want. – user3366706 Jul 08 '15 at 20:33
  • 1
    Yes, the ruby{} filter allows you to run arbitrary ruby code. – Alain Collins Jul 08 '15 at 21:10
  • 1
    The event API has changed, you now need use the set method ```event.set('message', rand(36**10).to_s(36))``` Hope this helps anyone else searching this – Jay Kravetz Sep 03 '20 at 16:14