michaelkeevildown / logstash-input-generator

Logstash Input to generate test data
Other
2 stars 0 forks source link

How to build and run.... #1

Closed michaelkeevildown closed 8 years ago

michaelkeevildown commented 8 years ago

How to install

1. Plugin Developement and Testing

Code

bundle install

2. Running your unpublished Plugin in Logstash

2.1 Run in a local Logstash clone

gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
# Logstash 2.3 and higher
bin/logstash-plugin install --no-verify

# Prior to Logstash 2.3
bin/plugin install --no-verify
bin/logstash -e 'filter {awesome {}}'

At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.

2.2 Run in an installed Logstash

You can use the same 2.1 method to run your plugin in an installed Logstash by editing its Gemfile and pointing the :path to your local plugin development directory or you can build the gem and install it using:

gem build logstash-filter-awesome.gemspec
# Logstash 2.3 and higher
bin/logstash-plugin install --no-verify

# Prior to Logstash 2.3
bin/plugin install --no-verify

How to run

How to load plugin into Logstash

cd {logstash install}

./bin/plugin install ~/{location of plugin repo}/logstash-input-generator/logstash-input-generator-2.0.4.gem

Logstash config

input {
  generator {
    schema_path => "~/logstash-2.2.2/schema/event.json"
    schema_refresh_interval => 1
  }
}

output {
  stdout { codec => rubydebug }
}

Event Schema

{
  "event_speed": 1,
  "locale": "en-GB",
  "fields": [
    {
      "group": "common",
      "type": "string",
      "key": "common-starter",
      "value": "#############     start     ########################"
    },
    {
      "group": "common",
      "type": "string",
      "key": "string_name",
      "value": "this is a test string"
    },
    {
      "group": "common",
      "type": "integer",
      "key": "number_range",
      "value": "random",
      "range": {
        "min": 10,
        "max": 100
      }
    },
    {
      "group": "common",
      "type": "integer",
      "key": "number_12",
      "value": 12
    },
    {
      "group": "common",
      "type": "integer",
      "key": "integer_random",
      "random": true
    },
    {
      "group": "common",
      "type": "string",
      "key": "common-breaker",
      "value": "#############     common     ########################"
    },
    {
      "group": "finance",
      "type": "credit_card_number",
      "key": "credit_card_number",
      "make": "visa"
    },
    {
      "group": "finance",
      "type": "credit_card_type",
      "key": "credit_card_type"
    },
    {
      "group": "finance",
      "type": "credit_card_expiry",
      "key": "credit_card_expiry"
    },
    {
      "group": "finance",
      "type": "bitcoin_address",
      "key": "bitcoin_address"
    },
    {
      "group": "finance",
      "type": "bitcoin_testnet_address",
      "key": "bitcoin_testnet_address"
    },
    {
      "group": "common",
      "type": "string",
      "key": "finance-breaker",
      "value": "#############     finance     ########################"
    },
    {
      "group": "internet",
      "type": "ipv4",
      "key": "ipv4"
    },
    {
      "group": "internet",
      "type": "ipv4",
      "sub-type": "ipv4_cidr",
      "key": "ipv4_cidr"
    },
    {
      "group": "internet",
      "type": "ipv6",
      "key": "ipv6"
    },
    {
      "group": "internet",
      "type": "ipv6",
      "sub-type": "ipv6_cidr",
      "key": "ipv6_cidr"
    },
    {
      "group": "internet",
      "type": "email",
      "key": "email_address"
    },
    {
      "group": "internet",
      "type": "email",
      "key": "complex_email_address",
      "properties": {
        "name": "michael"
      }
    },
    {
      "group": "internet",
      "type": "username",
      "key": "username"
    },
    {
      "group": "internet",
      "type": "password",
      "key": "simple_password"
    },
    {
      "group": "internet",
      "type": "password",
      "key": "password",
      "properties": {
        "min": 20,
        "max": 30
      }
    },
    {
      "group": "internet",
      "type": "password",
      "key": "special_password",
      "properties": {
        "min": 20,
        "max": 30,
        "special_chars": true
      }
    },
    {
      "group": "internet",
      "type": "domain",
      "key": "domain"
    },
    {
      "group": "internet",
      "type": "domain",
      "sub-type": "domain_word",
      "key": "domain_word"
    },
    {
      "group": "internet",
      "type": "domain",
      "sub-type": "domain_suffix",
      "key": "domain_suffix"
    },
    {
      "group": "internet",
      "type": "mac_address",
      "key": "mac_address"
    },
    {
      "group": "internet",
      "type": "url",
      "key": "url"
    },
    {
      "group": "internet",
      "type": "url",
      "key": "url_custom",
      "properties": {
        "domain": "text.com"
      }
    },
    {
      "group": "internet",
      "type": "url",
      "key": "url_custom_2",
      "properties": {
        "domain": "text.com",
        "uri": "/google.html"
      }
    },
    {
      "group": "common",
      "type": "string",
      "key": "internet-breaker",
      "value": "#############     internet     ########################"
    },
    {
      "group": "address",
      "type": "city",
      "key": "city"
    },{
      "group": "address",
      "type": "street_name",
      "key": "street_name"
    },{
      "group": "address",
      "type": "street_name",
      "key": "street_name"
    },{
      "group": "address",
      "type": "secondary_address",
      "key": "secondary_address"
    },{
      "group": "address",
      "type": "building_number",
      "key": "building_number"
    },{
      "group": "address",
      "type": "zip_code",
      "key": "zip_code"
    },{
      "group": "address",
      "type": "zip",
      "key": "zip"
    },{
      "group": "address",
      "type": "postcode",
      "key": "postcode"
    },{
      "group": "address",
      "type": "time_zone",
      "key": "time_zone"
    },{
      "group": "address",
      "type": "street_suffix",
      "key": "street_suffix"
    },{
      "group": "address",
      "type": "city_prefix",
      "key": "city_prefix"
    },{
      "group": "address",
      "type": "city_suffix",
      "key": "city_suffix"
    },{
      "group": "address",
      "type": "state",
      "key": "state"
    },{
      "group": "address",
      "type": "state_abbr",
      "key": "state_abbr"
    },
    {
      "group": "address",
      "type": "state_abbr",
      "key": "state_abbr"
    },
    {
      "group": "common",
      "type": "string",
      "key": "address-breaker",
      "value": "#############     address     ########################"
    }
  ]
}

Logstash Output

{
                       "host" => "mkd.home",
             "common-starter" => "#############     start     ########################",
                "string_name" => "this is a test string",
               "number_range" => 56,
                  "number_12" => 12,
             "integer_random" => 854097889285041169,
             "common-breaker" => "#############     common     ########################",
         "credit_card_number" => "4240747080908088",
           "credit_card_type" => "maestro'",
         "credit_card_expiry" => "2017-04-26",
            "bitcoin_address" => "1BzwJRoG38poUmbFtMrQFQxVR9ehY3SbgM",
    "bitcoin_testnet_address" => "n3DYuoUHMVsiLXWymS14dT5ZCbBhjmKM6j",
            "finance-breaker" => "#############     finance     ########################",
                       "ipv4" => "57.146.128.159",
                  "ipv4_cidr" => "144.14.115.145/2",
                       "ipv6" => "1f68:ff5f:7475:4314:860a:f314:a718:aa3d",
                  "ipv6_cidr" => "f8e4:d3f3:c5f4:80b7:3693:3fee:aef0:3490/119",
              "email_address" => "yasmeen@yahoo.com",
      "complex_email_address" => "michael@gmail.com",
                   "username" => "jacklyn.mosciski",
            "simple_password" => "35NbZbRtE",
                   "password" => "Iz4gFa4dFgJuKhP39kTjD",
           "special_password" => "$*@#!%!$$^@tDnNo6kJxB",
                     "domain" => "torphalvorson.biz",
                "domain_word" => "hackett",
              "domain_suffix" => "name",
                "mac_address" => "00:8b:e6:81:10:d7",
                        "url" => "http://batz.org/luna.hirthe",
                 "url_custom" => "http://leschlegros.co/chadd",
               "url_custom_2" => "http://text.com/google.html",
           "internet-breaker" => "#############     internet     ########################",
                       "city" => "Altenwerthmouth",
            "address-breaker" => "#############     address     ########################",
                   "@version" => "1",
                 "@timestamp" => "2016-04-26T17:53:39.948Z"
}