logstash-lib 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +24 -0
- data/.tailor +8 -0
- data/.travis.yml +12 -0
- data/CHANGELOG +1185 -0
- data/CONTRIBUTING.md +61 -0
- data/CONTRIBUTORS +79 -0
- data/LICENSE +14 -0
- data/Makefile +460 -0
- data/README.md +120 -0
- data/STYLE.md +96 -0
- data/bin/logstash +37 -0
- data/bin/logstash-test +4 -0
- data/bin/logstash-web +4 -0
- data/bin/logstash.lib.sh +78 -0
- data/bot/check_pull_changelog.rb +89 -0
- data/docs/configuration.md +260 -0
- data/docs/docgen.rb +242 -0
- data/docs/extending/example-add-a-new-filter.md +121 -0
- data/docs/extending/index.md +91 -0
- data/docs/flags.md +43 -0
- data/docs/generate_index.rb +28 -0
- data/docs/index.html.erb +56 -0
- data/docs/learn.md +46 -0
- data/docs/life-of-an-event.md +109 -0
- data/docs/logging-tool-comparisons.md +60 -0
- data/docs/plugin-doc.html.erb +91 -0
- data/docs/plugin-milestones.md +41 -0
- data/docs/plugin-synopsis.html.erb +24 -0
- data/docs/release-engineering.md +46 -0
- data/docs/release-test-results.md +14 -0
- data/docs/repositories.md +35 -0
- data/docs/tutorials/10-minute-walkthrough/apache-elasticsearch.conf +35 -0
- data/docs/tutorials/10-minute-walkthrough/apache-parse.conf +33 -0
- data/docs/tutorials/10-minute-walkthrough/apache_log.1 +1 -0
- data/docs/tutorials/10-minute-walkthrough/apache_log.2.bz2 +0 -0
- data/docs/tutorials/10-minute-walkthrough/hello-search.conf +25 -0
- data/docs/tutorials/10-minute-walkthrough/hello.conf +16 -0
- data/docs/tutorials/10-minute-walkthrough/index.md +124 -0
- data/docs/tutorials/10-minute-walkthrough/step-5-output.txt +17 -0
- data/docs/tutorials/getting-started-centralized-overview-diagram.png +0 -0
- data/docs/tutorials/getting-started-centralized-overview-diagram.xml +1 -0
- data/docs/tutorials/getting-started-centralized.md +217 -0
- data/docs/tutorials/getting-started-simple.md +200 -0
- data/docs/tutorials/just-enough-rabbitmq-for-logstash.md +201 -0
- data/docs/tutorials/media/frontend-response-codes.png +0 -0
- data/docs/tutorials/metrics-from-logs.md +84 -0
- data/docs/tutorials/zeromq.md +118 -0
- data/extract_services.rb +29 -0
- data/gembag.rb +64 -0
- data/lib/logstash-event.rb +2 -0
- data/lib/logstash.rb +4 -0
- data/lib/logstash/JRUBY-6970-openssl.rb +22 -0
- data/lib/logstash/JRUBY-6970.rb +102 -0
- data/lib/logstash/agent.rb +305 -0
- data/lib/logstash/certs/cacert.pem +3895 -0
- data/lib/logstash/codecs/base.rb +49 -0
- data/lib/logstash/codecs/compress_spooler.rb +50 -0
- data/lib/logstash/codecs/dots.rb +18 -0
- data/lib/logstash/codecs/edn.rb +28 -0
- data/lib/logstash/codecs/edn_lines.rb +36 -0
- data/lib/logstash/codecs/fluent.rb +55 -0
- data/lib/logstash/codecs/graphite.rb +114 -0
- data/lib/logstash/codecs/json.rb +41 -0
- data/lib/logstash/codecs/json_lines.rb +52 -0
- data/lib/logstash/codecs/json_spooler.rb +22 -0
- data/lib/logstash/codecs/line.rb +58 -0
- data/lib/logstash/codecs/msgpack.rb +43 -0
- data/lib/logstash/codecs/multiline.rb +189 -0
- data/lib/logstash/codecs/netflow.rb +342 -0
- data/lib/logstash/codecs/netflow/util.rb +212 -0
- data/lib/logstash/codecs/noop.rb +19 -0
- data/lib/logstash/codecs/oldlogstashjson.rb +56 -0
- data/lib/logstash/codecs/plain.rb +48 -0
- data/lib/logstash/codecs/rubydebug.rb +22 -0
- data/lib/logstash/codecs/spool.rb +38 -0
- data/lib/logstash/config/Makefile +4 -0
- data/lib/logstash/config/config_ast.rb +380 -0
- data/lib/logstash/config/file.rb +39 -0
- data/lib/logstash/config/grammar.rb +3504 -0
- data/lib/logstash/config/grammar.treetop +241 -0
- data/lib/logstash/config/mixin.rb +464 -0
- data/lib/logstash/config/registry.rb +13 -0
- data/lib/logstash/config/test.conf +18 -0
- data/lib/logstash/errors.rb +10 -0
- data/lib/logstash/event.rb +262 -0
- data/lib/logstash/filters/advisor.rb +178 -0
- data/lib/logstash/filters/alter.rb +173 -0
- data/lib/logstash/filters/anonymize.rb +93 -0
- data/lib/logstash/filters/base.rb +190 -0
- data/lib/logstash/filters/checksum.rb +50 -0
- data/lib/logstash/filters/cidr.rb +76 -0
- data/lib/logstash/filters/cipher.rb +145 -0
- data/lib/logstash/filters/clone.rb +35 -0
- data/lib/logstash/filters/collate.rb +114 -0
- data/lib/logstash/filters/csv.rb +94 -0
- data/lib/logstash/filters/date.rb +244 -0
- data/lib/logstash/filters/dns.rb +201 -0
- data/lib/logstash/filters/drop.rb +32 -0
- data/lib/logstash/filters/elapsed.rb +256 -0
- data/lib/logstash/filters/elasticsearch.rb +73 -0
- data/lib/logstash/filters/environment.rb +27 -0
- data/lib/logstash/filters/extractnumbers.rb +84 -0
- data/lib/logstash/filters/gelfify.rb +52 -0
- data/lib/logstash/filters/geoip.rb +145 -0
- data/lib/logstash/filters/grep.rb +153 -0
- data/lib/logstash/filters/grok.rb +425 -0
- data/lib/logstash/filters/grokdiscovery.rb +75 -0
- data/lib/logstash/filters/i18n.rb +51 -0
- data/lib/logstash/filters/json.rb +90 -0
- data/lib/logstash/filters/json_encode.rb +52 -0
- data/lib/logstash/filters/kv.rb +232 -0
- data/lib/logstash/filters/metaevent.rb +68 -0
- data/lib/logstash/filters/metrics.rb +237 -0
- data/lib/logstash/filters/multiline.rb +241 -0
- data/lib/logstash/filters/mutate.rb +399 -0
- data/lib/logstash/filters/noop.rb +21 -0
- data/lib/logstash/filters/prune.rb +149 -0
- data/lib/logstash/filters/punct.rb +32 -0
- data/lib/logstash/filters/railsparallelrequest.rb +86 -0
- data/lib/logstash/filters/range.rb +142 -0
- data/lib/logstash/filters/ruby.rb +42 -0
- data/lib/logstash/filters/sleep.rb +111 -0
- data/lib/logstash/filters/split.rb +64 -0
- data/lib/logstash/filters/sumnumbers.rb +73 -0
- data/lib/logstash/filters/syslog_pri.rb +107 -0
- data/lib/logstash/filters/translate.rb +121 -0
- data/lib/logstash/filters/unique.rb +29 -0
- data/lib/logstash/filters/urldecode.rb +57 -0
- data/lib/logstash/filters/useragent.rb +112 -0
- data/lib/logstash/filters/uuid.rb +58 -0
- data/lib/logstash/filters/xml.rb +139 -0
- data/lib/logstash/filters/zeromq.rb +123 -0
- data/lib/logstash/filterworker.rb +122 -0
- data/lib/logstash/inputs/base.rb +125 -0
- data/lib/logstash/inputs/collectd.rb +306 -0
- data/lib/logstash/inputs/drupal_dblog.rb +323 -0
- data/lib/logstash/inputs/drupal_dblog/jdbcconnection.rb +66 -0
- data/lib/logstash/inputs/elasticsearch.rb +140 -0
- data/lib/logstash/inputs/eventlog.rb +129 -0
- data/lib/logstash/inputs/eventlog/racob_fix.rb +44 -0
- data/lib/logstash/inputs/exec.rb +69 -0
- data/lib/logstash/inputs/file.rb +146 -0
- data/lib/logstash/inputs/ganglia.rb +127 -0
- data/lib/logstash/inputs/ganglia/gmondpacket.rb +146 -0
- data/lib/logstash/inputs/ganglia/xdr.rb +327 -0
- data/lib/logstash/inputs/gelf.rb +138 -0
- data/lib/logstash/inputs/gemfire.rb +222 -0
- data/lib/logstash/inputs/generator.rb +97 -0
- data/lib/logstash/inputs/graphite.rb +41 -0
- data/lib/logstash/inputs/heroku.rb +51 -0
- data/lib/logstash/inputs/imap.rb +136 -0
- data/lib/logstash/inputs/irc.rb +84 -0
- data/lib/logstash/inputs/log4j.rb +136 -0
- data/lib/logstash/inputs/lumberjack.rb +53 -0
- data/lib/logstash/inputs/pipe.rb +57 -0
- data/lib/logstash/inputs/rabbitmq.rb +126 -0
- data/lib/logstash/inputs/rabbitmq/bunny.rb +118 -0
- data/lib/logstash/inputs/rabbitmq/hot_bunnies.rb +1 -0
- data/lib/logstash/inputs/rabbitmq/march_hare.rb +129 -0
- data/lib/logstash/inputs/redis.rb +263 -0
- data/lib/logstash/inputs/relp.rb +106 -0
- data/lib/logstash/inputs/s3.rb +279 -0
- data/lib/logstash/inputs/snmptrap.rb +87 -0
- data/lib/logstash/inputs/sqlite.rb +185 -0
- data/lib/logstash/inputs/sqs.rb +172 -0
- data/lib/logstash/inputs/stdin.rb +46 -0
- data/lib/logstash/inputs/stomp.rb +84 -0
- data/lib/logstash/inputs/syslog.rb +237 -0
- data/lib/logstash/inputs/tcp.rb +231 -0
- data/lib/logstash/inputs/threadable.rb +18 -0
- data/lib/logstash/inputs/twitter.rb +82 -0
- data/lib/logstash/inputs/udp.rb +81 -0
- data/lib/logstash/inputs/unix.rb +163 -0
- data/lib/logstash/inputs/varnishlog.rb +48 -0
- data/lib/logstash/inputs/websocket.rb +50 -0
- data/lib/logstash/inputs/wmi.rb +72 -0
- data/lib/logstash/inputs/xmpp.rb +81 -0
- data/lib/logstash/inputs/zenoss.rb +143 -0
- data/lib/logstash/inputs/zeromq.rb +165 -0
- data/lib/logstash/kibana.rb +113 -0
- data/lib/logstash/loadlibs.rb +9 -0
- data/lib/logstash/logging.rb +89 -0
- data/lib/logstash/monkeypatches-for-bugs.rb +2 -0
- data/lib/logstash/monkeypatches-for-debugging.rb +47 -0
- data/lib/logstash/monkeypatches-for-performance.rb +66 -0
- data/lib/logstash/multiqueue.rb +53 -0
- data/lib/logstash/namespace.rb +16 -0
- data/lib/logstash/outputs/base.rb +120 -0
- data/lib/logstash/outputs/boundary.rb +116 -0
- data/lib/logstash/outputs/circonus.rb +78 -0
- data/lib/logstash/outputs/cloudwatch.rb +351 -0
- data/lib/logstash/outputs/csv.rb +55 -0
- data/lib/logstash/outputs/datadog.rb +93 -0
- data/lib/logstash/outputs/datadog_metrics.rb +123 -0
- data/lib/logstash/outputs/elasticsearch.rb +332 -0
- data/lib/logstash/outputs/elasticsearch/elasticsearch-template.json +44 -0
- data/lib/logstash/outputs/elasticsearch_http.rb +256 -0
- data/lib/logstash/outputs/elasticsearch_river.rb +214 -0
- data/lib/logstash/outputs/email.rb +299 -0
- data/lib/logstash/outputs/exec.rb +40 -0
- data/lib/logstash/outputs/file.rb +180 -0
- data/lib/logstash/outputs/ganglia.rb +75 -0
- data/lib/logstash/outputs/gelf.rb +208 -0
- data/lib/logstash/outputs/gemfire.rb +103 -0
- data/lib/logstash/outputs/google_bigquery.rb +570 -0
- data/lib/logstash/outputs/google_cloud_storage.rb +431 -0
- data/lib/logstash/outputs/graphite.rb +143 -0
- data/lib/logstash/outputs/graphtastic.rb +185 -0
- data/lib/logstash/outputs/hipchat.rb +80 -0
- data/lib/logstash/outputs/http.rb +142 -0
- data/lib/logstash/outputs/irc.rb +80 -0
- data/lib/logstash/outputs/jira.rb +109 -0
- data/lib/logstash/outputs/juggernaut.rb +105 -0
- data/lib/logstash/outputs/librato.rb +146 -0
- data/lib/logstash/outputs/loggly.rb +93 -0
- data/lib/logstash/outputs/lumberjack.rb +51 -0
- data/lib/logstash/outputs/metriccatcher.rb +103 -0
- data/lib/logstash/outputs/mongodb.rb +81 -0
- data/lib/logstash/outputs/nagios.rb +119 -0
- data/lib/logstash/outputs/nagios_nsca.rb +123 -0
- data/lib/logstash/outputs/null.rb +18 -0
- data/lib/logstash/outputs/opentsdb.rb +101 -0
- data/lib/logstash/outputs/pagerduty.rb +79 -0
- data/lib/logstash/outputs/pipe.rb +132 -0
- data/lib/logstash/outputs/rabbitmq.rb +96 -0
- data/lib/logstash/outputs/rabbitmq/bunny.rb +135 -0
- data/lib/logstash/outputs/rabbitmq/hot_bunnies.rb +1 -0
- data/lib/logstash/outputs/rabbitmq/march_hare.rb +143 -0
- data/lib/logstash/outputs/redis.rb +245 -0
- data/lib/logstash/outputs/riak.rb +152 -0
- data/lib/logstash/outputs/riemann.rb +109 -0
- data/lib/logstash/outputs/s3.rb +356 -0
- data/lib/logstash/outputs/sns.rb +124 -0
- data/lib/logstash/outputs/solr_http.rb +78 -0
- data/lib/logstash/outputs/sqs.rb +141 -0
- data/lib/logstash/outputs/statsd.rb +116 -0
- data/lib/logstash/outputs/stdout.rb +53 -0
- data/lib/logstash/outputs/stomp.rb +67 -0
- data/lib/logstash/outputs/syslog.rb +145 -0
- data/lib/logstash/outputs/tcp.rb +145 -0
- data/lib/logstash/outputs/udp.rb +38 -0
- data/lib/logstash/outputs/websocket.rb +46 -0
- data/lib/logstash/outputs/websocket/app.rb +29 -0
- data/lib/logstash/outputs/websocket/pubsub.rb +45 -0
- data/lib/logstash/outputs/xmpp.rb +78 -0
- data/lib/logstash/outputs/zabbix.rb +108 -0
- data/lib/logstash/outputs/zeromq.rb +125 -0
- data/lib/logstash/pipeline.rb +286 -0
- data/lib/logstash/plugin.rb +150 -0
- data/lib/logstash/plugin_mixins/aws_config.rb +93 -0
- data/lib/logstash/program.rb +15 -0
- data/lib/logstash/runner.rb +238 -0
- data/lib/logstash/sized_queue.rb +8 -0
- data/lib/logstash/test.rb +183 -0
- data/lib/logstash/threadwatchdog.rb +37 -0
- data/lib/logstash/time_addon.rb +33 -0
- data/lib/logstash/util.rb +106 -0
- data/lib/logstash/util/buftok.rb +139 -0
- data/lib/logstash/util/charset.rb +39 -0
- data/lib/logstash/util/fieldreference.rb +50 -0
- data/lib/logstash/util/password.rb +25 -0
- data/lib/logstash/util/prctl.rb +11 -0
- data/lib/logstash/util/relp.rb +326 -0
- data/lib/logstash/util/require-helper.rb +18 -0
- data/lib/logstash/util/socket_peer.rb +7 -0
- data/lib/logstash/util/zenoss.rb +566 -0
- data/lib/logstash/util/zeromq.rb +47 -0
- data/lib/logstash/version.rb +6 -0
- data/locales/en.yml +170 -0
- data/logstash-event.gemspec +29 -0
- data/logstash.gemspec +128 -0
- data/patterns/firewalls +60 -0
- data/patterns/grok-patterns +91 -0
- data/patterns/haproxy +37 -0
- data/patterns/java +3 -0
- data/patterns/linux-syslog +14 -0
- data/patterns/mcollective +1 -0
- data/patterns/mcollective-patterns +4 -0
- data/patterns/nagios +108 -0
- data/patterns/postgresql +3 -0
- data/patterns/redis +3 -0
- data/patterns/ruby +2 -0
- data/pkg/build.sh +135 -0
- data/pkg/centos/after-install.sh +1 -0
- data/pkg/centos/before-install.sh +10 -0
- data/pkg/centos/before-remove.sh +11 -0
- data/pkg/centos/sysconfig +15 -0
- data/pkg/debian/after-install.sh +5 -0
- data/pkg/debian/before-install.sh +13 -0
- data/pkg/debian/before-remove.sh +13 -0
- data/pkg/debian/build.sh +34 -0
- data/pkg/debian/debian/README +6 -0
- data/pkg/debian/debian/changelog +17 -0
- data/pkg/debian/debian/compat +1 -0
- data/pkg/debian/debian/control +16 -0
- data/pkg/debian/debian/copyright +27 -0
- data/pkg/debian/debian/dirs +19 -0
- data/pkg/debian/debian/docs +0 -0
- data/pkg/debian/debian/logstash.default +39 -0
- data/pkg/debian/debian/logstash.init +201 -0
- data/pkg/debian/debian/logstash.install +1 -0
- data/pkg/debian/debian/logstash.logrotate +9 -0
- data/pkg/debian/debian/logstash.postinst +68 -0
- data/pkg/debian/debian/logstash.postrm +23 -0
- data/pkg/debian/debian/manpage.1.ex +59 -0
- data/pkg/debian/debian/preinst.ex +37 -0
- data/pkg/debian/debian/prerm.ex +40 -0
- data/pkg/debian/debian/release.conf +5 -0
- data/pkg/debian/debian/rules +80 -0
- data/pkg/debian/debian/watch.ex +22 -0
- data/pkg/logrotate.conf +8 -0
- data/pkg/logstash-web.default +41 -0
- data/pkg/logstash-web.sysv.debian +201 -0
- data/pkg/logstash-web.upstart.ubuntu +18 -0
- data/pkg/logstash.default +45 -0
- data/pkg/logstash.sysv.debian +202 -0
- data/pkg/logstash.sysv.redhat +158 -0
- data/pkg/logstash.upstart.ubuntu +20 -0
- data/pkg/rpm/SOURCES/logstash.conf +26 -0
- data/pkg/rpm/SOURCES/logstash.init +80 -0
- data/pkg/rpm/SOURCES/logstash.logrotate +8 -0
- data/pkg/rpm/SOURCES/logstash.sysconfig +3 -0
- data/pkg/rpm/SOURCES/logstash.wrapper +105 -0
- data/pkg/rpm/SPECS/logstash.spec +180 -0
- data/pkg/rpm/readme.md +4 -0
- data/pkg/ubuntu/after-install.sh +7 -0
- data/pkg/ubuntu/before-install.sh +12 -0
- data/pkg/ubuntu/before-remove.sh +13 -0
- data/pull_release_note.rb +25 -0
- data/require-analyze.rb +22 -0
- data/spec/README.md +14 -0
- data/spec/codecs/edn.rb +40 -0
- data/spec/codecs/edn_lines.rb +53 -0
- data/spec/codecs/graphite.rb +96 -0
- data/spec/codecs/json.rb +57 -0
- data/spec/codecs/json_lines.rb +51 -0
- data/spec/codecs/json_spooler.rb +43 -0
- data/spec/codecs/msgpack.rb +39 -0
- data/spec/codecs/multiline.rb +60 -0
- data/spec/codecs/oldlogstashjson.rb +55 -0
- data/spec/codecs/plain.rb +35 -0
- data/spec/codecs/spool.rb +35 -0
- data/spec/conditionals/test.rb +323 -0
- data/spec/config.rb +31 -0
- data/spec/event.rb +165 -0
- data/spec/examples/fail2ban.rb +28 -0
- data/spec/examples/graphite-input.rb +41 -0
- data/spec/examples/mysql-slow-query.rb +70 -0
- data/spec/examples/parse-apache-logs.rb +66 -0
- data/spec/examples/parse-haproxy-logs.rb +115 -0
- data/spec/examples/syslog.rb +48 -0
- data/spec/filters/alter.rb +96 -0
- data/spec/filters/anonymize.rb +189 -0
- data/spec/filters/checksum.rb +41 -0
- data/spec/filters/clone.rb +67 -0
- data/spec/filters/collate.rb +122 -0
- data/spec/filters/csv.rb +174 -0
- data/spec/filters/date.rb +285 -0
- data/spec/filters/date_performance.rb +31 -0
- data/spec/filters/dns.rb +159 -0
- data/spec/filters/drop.rb +19 -0
- data/spec/filters/elapsed.rb +294 -0
- data/spec/filters/environment.rb +43 -0
- data/spec/filters/geoip.rb +62 -0
- data/spec/filters/grep.rb +342 -0
- data/spec/filters/grok.rb +473 -0
- data/spec/filters/grok/timeout2.rb +56 -0
- data/spec/filters/grok/timeouts.rb +39 -0
- data/spec/filters/i18n.rb +25 -0
- data/spec/filters/json.rb +72 -0
- data/spec/filters/json_encode.rb +37 -0
- data/spec/filters/kv.rb +403 -0
- data/spec/filters/metrics.rb +212 -0
- data/spec/filters/multiline.rb +119 -0
- data/spec/filters/mutate.rb +180 -0
- data/spec/filters/noop.rb +221 -0
- data/spec/filters/prune.rb +441 -0
- data/spec/filters/punct.rb +18 -0
- data/spec/filters/railsparallelrequest.rb +112 -0
- data/spec/filters/range.rb +169 -0
- data/spec/filters/split.rb +58 -0
- data/spec/filters/translate.rb +70 -0
- data/spec/filters/unique.rb +25 -0
- data/spec/filters/useragent.rb +42 -0
- data/spec/filters/xml.rb +157 -0
- data/spec/inputs/file.rb +107 -0
- data/spec/inputs/gelf.rb +52 -0
- data/spec/inputs/generator.rb +30 -0
- data/spec/inputs/imap.rb +60 -0
- data/spec/inputs/redis.rb +63 -0
- data/spec/inputs/relp.rb +70 -0
- data/spec/inputs/tcp.rb +101 -0
- data/spec/jar.rb +21 -0
- data/spec/outputs/csv.rb +266 -0
- data/spec/outputs/elasticsearch.rb +161 -0
- data/spec/outputs/elasticsearch_http.rb +240 -0
- data/spec/outputs/email.rb +173 -0
- data/spec/outputs/file.rb +82 -0
- data/spec/outputs/graphite.rb +236 -0
- data/spec/outputs/redis.rb +127 -0
- data/spec/speed.rb +20 -0
- data/spec/sqlite-test.rb +81 -0
- data/spec/support/LOGSTASH-733.rb +21 -0
- data/spec/support/LOGSTASH-820.rb +25 -0
- data/spec/support/akamai-grok.rb +26 -0
- data/spec/support/date-http.rb +17 -0
- data/spec/support/postwait1.rb +26 -0
- data/spec/support/pull375.rb +21 -0
- data/spec/test_utils.rb +125 -0
- data/spec/util/fieldeval_spec.rb +44 -0
- data/test/jenkins/config.xml.erb +74 -0
- data/test/jenkins/create-jobs.rb +23 -0
- data/test/jenkins/generatorjob.config.xml +66 -0
- data/tools/Gemfile +14 -0
- data/tools/Gemfile.jruby-1.9.lock +322 -0
- data/tools/Gemfile.rbx-2.1.lock +516 -0
- data/tools/Gemfile.ruby-1.9.1.lock +310 -0
- data/tools/Gemfile.ruby-2.0.0.lock +310 -0
- metadata +629 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "bindata"
|
|
3
|
+
require "ipaddr"
|
|
4
|
+
|
|
5
|
+
class IP4Addr < BinData::Primitive
|
|
6
|
+
endian :big
|
|
7
|
+
uint32 :storage
|
|
8
|
+
|
|
9
|
+
def set(val)
|
|
10
|
+
ip = IPAddr.new(val)
|
|
11
|
+
if ! ip.ipv4?
|
|
12
|
+
raise ArgumentError, "invalid IPv4 address '#{val}'"
|
|
13
|
+
end
|
|
14
|
+
self.storage = ip.to_i
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get
|
|
18
|
+
IPAddr.new_ntoh([self.storage].pack('N')).to_s
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class IP6Addr < BinData::Primitive
|
|
23
|
+
endian :big
|
|
24
|
+
uint128 :storage
|
|
25
|
+
|
|
26
|
+
def set(val)
|
|
27
|
+
ip = IPAddr.new(val)
|
|
28
|
+
if ! ip.ipv6?
|
|
29
|
+
raise ArgumentError, "invalid IPv6 address `#{val}'"
|
|
30
|
+
end
|
|
31
|
+
self.storage = ip.to_i
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get
|
|
35
|
+
IPAddr.new_ntoh((0..7).map { |i|
|
|
36
|
+
(self.storage >> (112 - 16 * i)) & 0xffff
|
|
37
|
+
}.pack('n8')).to_s
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class MacAddr < BinData::Primitive
|
|
42
|
+
array :bytes, :type => :uint8, :initial_length => 6
|
|
43
|
+
|
|
44
|
+
def set(val)
|
|
45
|
+
ints = val.split(/:/).collect { |int| int.to_i(16) }
|
|
46
|
+
self.bytes = ints
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get
|
|
50
|
+
self.bytes.collect { |byte| byte.to_s(16) }.join(":")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Header < BinData::Record
|
|
55
|
+
endian :big
|
|
56
|
+
uint16 :version
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class Netflow5PDU < BinData::Record
|
|
60
|
+
endian :big
|
|
61
|
+
uint16 :version
|
|
62
|
+
uint16 :flow_records
|
|
63
|
+
uint32 :uptime
|
|
64
|
+
uint32 :unix_sec
|
|
65
|
+
uint32 :unix_nsec
|
|
66
|
+
uint32 :flow_seq_num
|
|
67
|
+
uint8 :engine_type
|
|
68
|
+
uint8 :engine_id
|
|
69
|
+
bit2 :sampling_algorithm
|
|
70
|
+
bit14 :sampling_interval
|
|
71
|
+
array :records, :initial_length => :flow_records do
|
|
72
|
+
ip4_addr :ipv4_src_addr
|
|
73
|
+
ip4_addr :ipv4_dst_addr
|
|
74
|
+
ip4_addr :ipv4_next_hop
|
|
75
|
+
uint16 :input_snmp
|
|
76
|
+
uint16 :output_snmp
|
|
77
|
+
uint32 :in_pkts
|
|
78
|
+
uint32 :in_bytes
|
|
79
|
+
uint32 :first_switched
|
|
80
|
+
uint32 :last_switched
|
|
81
|
+
uint16 :l4_src_port
|
|
82
|
+
uint16 :l4_dst_port
|
|
83
|
+
skip :length => 1
|
|
84
|
+
uint8 :tcp_flags # Split up the TCP flags maybe?
|
|
85
|
+
uint8 :protocol
|
|
86
|
+
uint8 :src_tos
|
|
87
|
+
uint16 :src_as
|
|
88
|
+
uint16 :dst_as
|
|
89
|
+
uint8 :src_mask
|
|
90
|
+
uint8 :dst_mask
|
|
91
|
+
skip :length => 2
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class TemplateFlowset < BinData::Record
|
|
96
|
+
endian :big
|
|
97
|
+
array :templates, :read_until => lambda { array.num_bytes == flowset_length - 4 } do
|
|
98
|
+
uint16 :template_id
|
|
99
|
+
uint16 :field_count
|
|
100
|
+
array :fields, :initial_length => :field_count do
|
|
101
|
+
uint16 :field_type
|
|
102
|
+
uint16 :field_length
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class OptionFlowset < BinData::Record
|
|
108
|
+
endian :big
|
|
109
|
+
array :templates, :read_until => lambda { flowset_length - 4 - array.num_bytes <= 2 } do
|
|
110
|
+
uint16 :template_id
|
|
111
|
+
uint16 :scope_length
|
|
112
|
+
uint16 :option_length
|
|
113
|
+
array :scope_fields, :initial_length => lambda { scope_length / 4 } do
|
|
114
|
+
uint16 :field_type
|
|
115
|
+
uint16 :field_length
|
|
116
|
+
end
|
|
117
|
+
array :option_fields, :initial_length => lambda { option_length / 4 } do
|
|
118
|
+
uint16 :field_type
|
|
119
|
+
uint16 :field_length
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
skip :length => lambda { templates.length.odd? ? 2 : 0 }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class Netflow9PDU < BinData::Record
|
|
126
|
+
endian :big
|
|
127
|
+
uint16 :version
|
|
128
|
+
uint16 :flow_records
|
|
129
|
+
uint32 :uptime
|
|
130
|
+
uint32 :unix_sec
|
|
131
|
+
uint32 :flow_seq_num
|
|
132
|
+
uint32 :source_id
|
|
133
|
+
array :records, :read_until => :eof do
|
|
134
|
+
uint16 :flowset_id
|
|
135
|
+
uint16 :flowset_length
|
|
136
|
+
choice :flowset_data, :selection => :flowset_id do
|
|
137
|
+
template_flowset 0
|
|
138
|
+
option_flowset 1
|
|
139
|
+
string :default, :read_length => lambda { flowset_length - 4 }
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# https://gist.github.com/joshaven/184837
|
|
145
|
+
class Vash < Hash
|
|
146
|
+
def initialize(constructor = {})
|
|
147
|
+
@register ||= {}
|
|
148
|
+
if constructor.is_a?(Hash)
|
|
149
|
+
super()
|
|
150
|
+
merge(constructor)
|
|
151
|
+
else
|
|
152
|
+
super(constructor)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
|
157
|
+
alias_method :regular_reader, :[] unless method_defined?(:regular_reader)
|
|
158
|
+
|
|
159
|
+
def [](key)
|
|
160
|
+
sterilize(key)
|
|
161
|
+
clear(key) if expired?(key)
|
|
162
|
+
regular_reader(key)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def []=(key, *args)
|
|
166
|
+
if args.length == 2
|
|
167
|
+
value, ttl = args[1], args[0]
|
|
168
|
+
elsif args.length == 1
|
|
169
|
+
value, ttl = args[0], 60
|
|
170
|
+
else
|
|
171
|
+
raise ArgumentError, "Wrong number of arguments, expected 2 or 3, received: #{args.length+1}\n"+
|
|
172
|
+
"Example Usage: volatile_hash[:key]=value OR volatile_hash[:key, ttl]=value"
|
|
173
|
+
end
|
|
174
|
+
sterilize(key)
|
|
175
|
+
ttl(key, ttl)
|
|
176
|
+
regular_writer(key, value)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def merge(hsh)
|
|
180
|
+
hsh.map {|key,value| self[sterile(key)] = hsh[key]}
|
|
181
|
+
self
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def cleanup!
|
|
185
|
+
now = Time.now.to_i
|
|
186
|
+
@register.map {|k,v| clear(k) if v < now}
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def clear(key)
|
|
190
|
+
sterilize(key)
|
|
191
|
+
@register.delete key
|
|
192
|
+
self.delete key
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
private
|
|
196
|
+
def expired?(key)
|
|
197
|
+
Time.now.to_i > @register[key].to_i
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def ttl(key, secs=60)
|
|
201
|
+
@register[key] = Time.now.to_i + secs.to_i
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def sterile(key)
|
|
205
|
+
String === key ? key.chomp('!').chomp('=') : key.to_s.chomp('!').chomp('=').to_sym
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def sterilize(key)
|
|
209
|
+
key = sterile(key)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "logstash/codecs/base"
|
|
3
|
+
|
|
4
|
+
class LogStash::Codecs::Noop < LogStash::Codecs::Base
|
|
5
|
+
config_name "noop"
|
|
6
|
+
|
|
7
|
+
milestone 1
|
|
8
|
+
|
|
9
|
+
public
|
|
10
|
+
def decode(data)
|
|
11
|
+
yield data
|
|
12
|
+
end # def decode
|
|
13
|
+
|
|
14
|
+
public
|
|
15
|
+
def encode(data)
|
|
16
|
+
@on_event.call data
|
|
17
|
+
end # def encode
|
|
18
|
+
|
|
19
|
+
end # class LogStash::Codecs::Noop
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "logstash/codecs/base"
|
|
3
|
+
|
|
4
|
+
class LogStash::Codecs::OldLogStashJSON < LogStash::Codecs::Base
|
|
5
|
+
config_name "oldlogstashjson"
|
|
6
|
+
milestone 2
|
|
7
|
+
|
|
8
|
+
# Map from v0 name to v1 name.
|
|
9
|
+
# Note: @source is gone and has no similar field.
|
|
10
|
+
V0_TO_V1 = {"@timestamp" => "@timestamp", "@message" => "message",
|
|
11
|
+
"@tags" => "tags", "@type" => "type",
|
|
12
|
+
"@source_host" => "host", "@source_path" => "path"}
|
|
13
|
+
|
|
14
|
+
public
|
|
15
|
+
def decode(data)
|
|
16
|
+
begin
|
|
17
|
+
obj = JSON.parse(data.force_encoding("UTF-8"))
|
|
18
|
+
rescue JSON::ParserError => e
|
|
19
|
+
@logger.info("JSON parse failure. Falling back to plain-text", :error => e, :data => data)
|
|
20
|
+
yield LogStash::Event.new("message" => data)
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
h = {}
|
|
25
|
+
|
|
26
|
+
# Convert the old logstash schema to the new one.
|
|
27
|
+
V0_TO_V1.each do |key, val|
|
|
28
|
+
h[val] = obj[key] if obj.include?(key)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
h.merge!(obj["@fields"]) if obj["@fields"].is_a?(Hash)
|
|
32
|
+
yield LogStash::Event.new(h)
|
|
33
|
+
end # def decode
|
|
34
|
+
|
|
35
|
+
public
|
|
36
|
+
def encode(data)
|
|
37
|
+
h = {}
|
|
38
|
+
|
|
39
|
+
# Convert the new logstash schema to the old one.
|
|
40
|
+
V0_TO_V1.each do |key, val|
|
|
41
|
+
h[key] = data[val] if data.include?(val)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
data.to_hash.each do |field, val|
|
|
45
|
+
# TODO: might be better to V1_TO_V0 = V0_TO_V1.invert during
|
|
46
|
+
# initialization than V0_TO_V1.has_value? within loop
|
|
47
|
+
next if field == "@version" or V0_TO_V1.has_value?(field)
|
|
48
|
+
h["@fields"] = {} if h["@fields"].nil?
|
|
49
|
+
h["@fields"][field] = val
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Tack on a \n because JSON outputs 1.1.x had them.
|
|
53
|
+
@on_event.call(h.to_json + "\n")
|
|
54
|
+
end # def encode
|
|
55
|
+
|
|
56
|
+
end # class LogStash::Codecs::OldLogStashJSON
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "logstash/codecs/base"
|
|
3
|
+
require "logstash/util/charset"
|
|
4
|
+
|
|
5
|
+
# The "plain" codec is for plain text with no delimiting between events.
|
|
6
|
+
#
|
|
7
|
+
# This is mainly useful on inputs and outputs that already have a defined
|
|
8
|
+
# framing in their transport protocol (such as zeromq, rabbitmq, redis, etc)
|
|
9
|
+
class LogStash::Codecs::Plain < LogStash::Codecs::Base
|
|
10
|
+
config_name "plain"
|
|
11
|
+
milestone 3
|
|
12
|
+
|
|
13
|
+
# Set the message you which to emit for each event. This supports sprintf
|
|
14
|
+
# strings.
|
|
15
|
+
#
|
|
16
|
+
# This setting only affects outputs (encoding of events).
|
|
17
|
+
config :format, :validate => :string
|
|
18
|
+
|
|
19
|
+
# The character encoding used in this input. Examples include "UTF-8"
|
|
20
|
+
# and "cp1252"
|
|
21
|
+
#
|
|
22
|
+
# This setting is useful if your log files are in Latin-1 (aka cp1252)
|
|
23
|
+
# or in another character set other than UTF-8.
|
|
24
|
+
#
|
|
25
|
+
# This only affects "plain" format logs since json is UTF-8 already.
|
|
26
|
+
config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
|
|
27
|
+
|
|
28
|
+
public
|
|
29
|
+
def register
|
|
30
|
+
@converter = LogStash::Util::Charset.new(@charset)
|
|
31
|
+
@converter.logger = @logger
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
public
|
|
35
|
+
def decode(data)
|
|
36
|
+
yield LogStash::Event.new("message" => @converter.convert(data))
|
|
37
|
+
end # def decode
|
|
38
|
+
|
|
39
|
+
public
|
|
40
|
+
def encode(data)
|
|
41
|
+
if data.is_a? LogStash::Event and @format
|
|
42
|
+
@on_event.call(data.sprintf(@format))
|
|
43
|
+
else
|
|
44
|
+
@on_event.call(data.to_s)
|
|
45
|
+
end
|
|
46
|
+
end # def encode
|
|
47
|
+
|
|
48
|
+
end # class LogStash::Codecs::Plain
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "logstash/codecs/base"
|
|
3
|
+
|
|
4
|
+
class LogStash::Codecs::RubyDebug < LogStash::Codecs::Base
|
|
5
|
+
config_name "rubydebug"
|
|
6
|
+
milestone 3
|
|
7
|
+
|
|
8
|
+
def register
|
|
9
|
+
require "ap"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
public
|
|
13
|
+
def decode(data)
|
|
14
|
+
raise "Not implemented"
|
|
15
|
+
end # def decode
|
|
16
|
+
|
|
17
|
+
public
|
|
18
|
+
def encode(data)
|
|
19
|
+
@on_event.call(data.to_hash.awesome_inspect + "\n")
|
|
20
|
+
end # def encode
|
|
21
|
+
|
|
22
|
+
end # class LogStash::Codecs::Dots
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "logstash/codecs/base"
|
|
3
|
+
|
|
4
|
+
class LogStash::Codecs::Spool < LogStash::Codecs::Base
|
|
5
|
+
config_name 'spool'
|
|
6
|
+
milestone 1
|
|
7
|
+
config :spool_size, :validate => :number, :default => 50
|
|
8
|
+
|
|
9
|
+
attr_reader :buffer
|
|
10
|
+
|
|
11
|
+
public
|
|
12
|
+
def decode(data)
|
|
13
|
+
data.each do |event|
|
|
14
|
+
yield event
|
|
15
|
+
end
|
|
16
|
+
end # def decode
|
|
17
|
+
|
|
18
|
+
public
|
|
19
|
+
def encode(data)
|
|
20
|
+
@buffer = [] if @buffer.nil?
|
|
21
|
+
#buffer size is hard coded for now until a
|
|
22
|
+
#better way to pass args into codecs is implemented
|
|
23
|
+
if @buffer.length >= @spool_size
|
|
24
|
+
@on_event.call @buffer
|
|
25
|
+
@buffer = []
|
|
26
|
+
else
|
|
27
|
+
@buffer << data
|
|
28
|
+
end
|
|
29
|
+
end # def encode
|
|
30
|
+
|
|
31
|
+
public
|
|
32
|
+
def teardown
|
|
33
|
+
if !@buffer.nil? and @buffer.length > 0
|
|
34
|
+
@on_event.call @buffer
|
|
35
|
+
end
|
|
36
|
+
@buffer = []
|
|
37
|
+
end
|
|
38
|
+
end # class LogStash::Codecs::Spool
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "treetop"
|
|
3
|
+
class Treetop::Runtime::SyntaxNode
|
|
4
|
+
def compile
|
|
5
|
+
return "" if elements.nil?
|
|
6
|
+
return elements.collect(&:compile).reject(&:empty?).join("")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def recursive_inject(results=[], &block)
|
|
10
|
+
if !elements.nil?
|
|
11
|
+
elements.each do |element|
|
|
12
|
+
if block.call(element)
|
|
13
|
+
results << element
|
|
14
|
+
else
|
|
15
|
+
element.recursive_inject(results, &block)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
return results
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def recursive_select(klass)
|
|
23
|
+
return recursive_inject { |e| e.is_a?(klass) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def recursive_inject_parent(results=[], &block)
|
|
27
|
+
if !parent.nil?
|
|
28
|
+
if block.call(parent)
|
|
29
|
+
results << parent
|
|
30
|
+
else
|
|
31
|
+
parent.recursive_inject_parent(results, &block)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
return results
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def recursive_select_parent(results=[], klass)
|
|
38
|
+
return recursive_inject_parent(results) { |e| e.is_a?(klass) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
module LogStash; module Config; module AST
|
|
43
|
+
class Node < Treetop::Runtime::SyntaxNode; end
|
|
44
|
+
class Config < Node
|
|
45
|
+
def compile
|
|
46
|
+
# TODO(sissel): Move this into config/config_ast.rb
|
|
47
|
+
code = []
|
|
48
|
+
code << "@inputs = []"
|
|
49
|
+
code << "@filters = []"
|
|
50
|
+
code << "@outputs = []"
|
|
51
|
+
sections = recursive_select(LogStash::Config::AST::PluginSection)
|
|
52
|
+
sections.each do |s|
|
|
53
|
+
code << s.compile_initializer
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# start inputs
|
|
57
|
+
#code << "class << self"
|
|
58
|
+
definitions = []
|
|
59
|
+
|
|
60
|
+
["filter", "output"].each do |type|
|
|
61
|
+
#definitions << "def #{type}(event)"
|
|
62
|
+
definitions << "@#{type}_func = lambda do |event, &block|"
|
|
63
|
+
if type == "filter"
|
|
64
|
+
definitions << " extra_events = []"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
definitions << " @logger.info? && @logger.info(\"#{type} received\", :event => event)"
|
|
68
|
+
sections.select { |s| s.plugin_type.text_value == type }.each do |s|
|
|
69
|
+
definitions << s.compile.split("\n", -1).map { |e| " #{e}" }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
if type == "filter"
|
|
73
|
+
definitions << " extra_events.each(&block)"
|
|
74
|
+
end
|
|
75
|
+
definitions << "end"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
code += definitions.join("\n").split("\n", -1).collect { |l| " #{l}" }
|
|
79
|
+
#code << "end"
|
|
80
|
+
return code.join("\n")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class Comment < Node; end
|
|
85
|
+
class Whitespace < Node; end
|
|
86
|
+
class PluginSection < Node
|
|
87
|
+
@@i = 0
|
|
88
|
+
# Generate ruby code to initialize all the plugins.
|
|
89
|
+
def compile_initializer
|
|
90
|
+
generate_variables
|
|
91
|
+
code = []
|
|
92
|
+
@variables.collect do |plugin, name|
|
|
93
|
+
code << "#{name} = #{plugin.compile_initializer}"
|
|
94
|
+
code << "@#{plugin.plugin_type}s << #{name}"
|
|
95
|
+
end
|
|
96
|
+
return code.join("\n")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def variable(object)
|
|
100
|
+
generate_variables
|
|
101
|
+
return @variables[object]
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def generate_variables
|
|
105
|
+
return if !@variables.nil?
|
|
106
|
+
@variables = {}
|
|
107
|
+
plugins = recursive_select(Plugin)
|
|
108
|
+
|
|
109
|
+
plugins.each do |plugin|
|
|
110
|
+
# Unique number for every plugin.
|
|
111
|
+
@@i += 1
|
|
112
|
+
# store things as ivars, like @filter_grok_3
|
|
113
|
+
var = "@#{plugin.plugin_type}_#{plugin.plugin_name}_#{@@i}"
|
|
114
|
+
@variables[plugin] = var
|
|
115
|
+
end
|
|
116
|
+
return @variables
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class Plugins < Node; end
|
|
122
|
+
class Plugin < Node
|
|
123
|
+
def plugin_type
|
|
124
|
+
if recursive_select_parent(Plugin).any?
|
|
125
|
+
return "codec"
|
|
126
|
+
else
|
|
127
|
+
return recursive_select_parent(PluginSection).first.plugin_type.text_value
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def plugin_name
|
|
132
|
+
return name.text_value
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def variable_name
|
|
136
|
+
return recursive_select_parent(PluginSection).first.variable(self)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def compile_initializer
|
|
140
|
+
# If any parent is a Plugin, this must be a codec.
|
|
141
|
+
|
|
142
|
+
if attributes.elements.nil?
|
|
143
|
+
return "plugin(#{plugin_type.inspect}, #{plugin_name.inspect})" << (plugin_type == "codec" ? "" : "\n")
|
|
144
|
+
else
|
|
145
|
+
settings = attributes.recursive_select(Attribute).collect(&:compile).reject(&:empty?)
|
|
146
|
+
|
|
147
|
+
attributes_code = "LogStash::Util.hash_merge_many(#{settings.map { |c| "{ #{c} }" }.join(", ")})"
|
|
148
|
+
return "plugin(#{plugin_type.inspect}, #{plugin_name.inspect}, #{attributes_code})" << (plugin_type == "codec" ? "" : "\n")
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def compile
|
|
153
|
+
case plugin_type
|
|
154
|
+
when "input"
|
|
155
|
+
return "start_input(#{variable_name})"
|
|
156
|
+
when "filter"
|
|
157
|
+
# This is some pretty stupid code, honestly.
|
|
158
|
+
# I'd prefer much if it were put into the Pipeline itself
|
|
159
|
+
# and this should simply compile to
|
|
160
|
+
# #{variable_name}.filter(event)
|
|
161
|
+
return [
|
|
162
|
+
"newevents = []",
|
|
163
|
+
"extra_events.each do |event|",
|
|
164
|
+
" #{variable_name}.filter(event) do |newevent|",
|
|
165
|
+
" newevents << newevent",
|
|
166
|
+
" end",
|
|
167
|
+
"end",
|
|
168
|
+
"extra_events += newevents",
|
|
169
|
+
|
|
170
|
+
"#{variable_name}.filter(event) do |newevent|",
|
|
171
|
+
" extra_events << newevent",
|
|
172
|
+
"end",
|
|
173
|
+
"if event.cancelled?",
|
|
174
|
+
" extra_events.each(&block)",
|
|
175
|
+
" return",
|
|
176
|
+
"end",
|
|
177
|
+
].map { |l| "#{l}\n" }.join("")
|
|
178
|
+
when "output"
|
|
179
|
+
return "#{variable_name}.handle(event)\n"
|
|
180
|
+
when "codec"
|
|
181
|
+
settings = attributes.recursive_select(Attribute).collect(&:compile).reject(&:empty?)
|
|
182
|
+
attributes_code = "LogStash::Util.hash_merge_many(#{settings.map { |c| "{ #{c} }" }.join(", ")})"
|
|
183
|
+
return "plugin(#{plugin_type.inspect}, #{plugin_name.inspect}, #{attributes_code})"
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
class Name < Node
|
|
189
|
+
def compile
|
|
190
|
+
return text_value.inspect
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
class Attribute < Node
|
|
194
|
+
def compile
|
|
195
|
+
return %Q(#{name.compile} => #{value.compile})
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
class RValue < Node; end
|
|
199
|
+
class Value < RValue; end
|
|
200
|
+
|
|
201
|
+
module Unicode
|
|
202
|
+
def self.wrap(text)
|
|
203
|
+
return "(" + text.inspect + ".force_encoding(\"UTF-8\")" + ")"
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
class Bareword < Value
|
|
208
|
+
def compile
|
|
209
|
+
return Unicode.wrap(text_value)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
class String < Value
|
|
213
|
+
def compile
|
|
214
|
+
return Unicode.wrap(text_value[1...-1])
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
class RegExp < Value
|
|
218
|
+
def compile
|
|
219
|
+
return "Regexp.new(" + Unicode.wrap(text_value[1...-1]) + ")"
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
class Number < Value
|
|
223
|
+
def compile
|
|
224
|
+
return text_value
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
class Array < Value
|
|
228
|
+
def compile
|
|
229
|
+
return "[" << recursive_select(Value).collect(&:compile).reject(&:empty?).join(", ") << "]"
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
class Hash < Value
|
|
233
|
+
def compile
|
|
234
|
+
return "{" << recursive_select(HashEntry).collect(&:compile).reject(&:empty?).join(", ") << "}"
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
class HashEntries < Node; end
|
|
238
|
+
class HashEntry < Node
|
|
239
|
+
def compile
|
|
240
|
+
return %Q(#{name.compile} => #{value.compile})
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
class BranchOrPlugin < Node; end
|
|
245
|
+
|
|
246
|
+
class Branch < Node
|
|
247
|
+
def compile
|
|
248
|
+
return super + "end\n"
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
class If < Node
|
|
252
|
+
def compile
|
|
253
|
+
children = recursive_inject { |e| e.is_a?(Branch) || e.is_a?(Plugin) }
|
|
254
|
+
return "if #{condition.compile}\n" \
|
|
255
|
+
<< children.collect(&:compile).map { |s| s.split("\n", -1).map { |l| " " + l }.join("\n") }.join("") << "\n"
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
class Elsif < Node
|
|
259
|
+
def compile
|
|
260
|
+
children = recursive_inject { |e| e.is_a?(Branch) || e.is_a?(Plugin) }
|
|
261
|
+
return "elsif #{condition.compile}\n" \
|
|
262
|
+
<< children.collect(&:compile).map { |s| s.split("\n", -1).map { |l| " " + l }.join("\n") }.join("") << "\n"
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
class Else < Node
|
|
266
|
+
def compile
|
|
267
|
+
children = recursive_inject { |e| e.is_a?(Branch) || e.is_a?(Plugin) }
|
|
268
|
+
return "else\n" \
|
|
269
|
+
<< children.collect(&:compile).map { |s| s.split("\n", -1).map { |l| " " + l }.join("\n") }.join("") << "\n"
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
class Condition < Node
|
|
274
|
+
def compile
|
|
275
|
+
return "(#{super})"
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
module Expression
|
|
280
|
+
def compile
|
|
281
|
+
return "(#{super})"
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
module NegativeExpression
|
|
286
|
+
def compile
|
|
287
|
+
return "!(#{super})"
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
module ComparisonExpression; end
|
|
292
|
+
|
|
293
|
+
module InExpression
|
|
294
|
+
def compile
|
|
295
|
+
item, list = recursive_select(LogStash::Config::AST::RValue)
|
|
296
|
+
return "(x = #{list.compile}; x.respond_to?(:include?) && x.include?(#{item.compile}))"
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
module NotInExpression
|
|
301
|
+
def compile
|
|
302
|
+
item, list = recursive_select(LogStash::Config::AST::RValue)
|
|
303
|
+
return "(x = #{list.compile}; !x.respond_to?(:include?) || !x.include?(#{item.compile}))"
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
class MethodCall < Node
|
|
308
|
+
def compile
|
|
309
|
+
arguments = recursive_inject { |e| [String, Number, Selector, Array, MethodCall].any? { |c| e.is_a?(c) } }
|
|
310
|
+
return "#{method.text_value}(" << arguments.collect(&:compile).join(", ") << ")"
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
class RegexpExpression < Node
|
|
315
|
+
def compile
|
|
316
|
+
operator = recursive_select(LogStash::Config::AST::RegExpOperator).first.text_value
|
|
317
|
+
item, regexp = recursive_select(LogStash::Config::AST::RValue)
|
|
318
|
+
# Compile strings to regexp's
|
|
319
|
+
if regexp.is_a?(LogStash::Config::AST::String)
|
|
320
|
+
regexp = "/#{regexp.text_value[1..-2]}/"
|
|
321
|
+
else
|
|
322
|
+
regexp = regexp.compile
|
|
323
|
+
end
|
|
324
|
+
return "(#{item.compile} #{operator} #{regexp})"
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
module ComparisonOperator
|
|
329
|
+
def compile
|
|
330
|
+
return " #{text_value} "
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
module RegExpOperator
|
|
334
|
+
def compile
|
|
335
|
+
return " #{text_value} "
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
module BooleanOperator
|
|
339
|
+
def compile
|
|
340
|
+
return " #{text_value} "
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
class Selector < RValue
|
|
344
|
+
def compile
|
|
345
|
+
return "event[#{text_value.inspect}]"
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
class SelectorElement < Node; end
|
|
349
|
+
end; end; end
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
# Monkeypatch Treetop::Runtime::SyntaxNode's inspect method to skip
|
|
353
|
+
# any Whitespace or SyntaxNodes with no children.
|
|
354
|
+
class Treetop::Runtime::SyntaxNode
|
|
355
|
+
def _inspect(indent="")
|
|
356
|
+
em = extension_modules
|
|
357
|
+
interesting_methods = methods-[em.last ? em.last.methods : nil]-self.class.instance_methods
|
|
358
|
+
im = interesting_methods.size > 0 ? " (#{interesting_methods.join(",")})" : ""
|
|
359
|
+
tv = text_value
|
|
360
|
+
tv = "...#{tv[-20..-1]}" if tv.size > 20
|
|
361
|
+
|
|
362
|
+
indent +
|
|
363
|
+
self.class.to_s.sub(/.*:/,'') +
|
|
364
|
+
em.map{|m| "+"+m.to_s.sub(/.*:/,'')}*"" +
|
|
365
|
+
" offset=#{interval.first}" +
|
|
366
|
+
", #{tv.inspect}" +
|
|
367
|
+
im +
|
|
368
|
+
(elements && elements.size > 0 ?
|
|
369
|
+
":" +
|
|
370
|
+
(elements.select { |e| !e.is_a?(LogStash::Config::AST::Whitespace) && e.elements && e.elements.size > 0 }||[]).map{|e|
|
|
371
|
+
begin
|
|
372
|
+
"\n"+e.inspect(indent+" ")
|
|
373
|
+
rescue # Defend against inspect not taking a parameter
|
|
374
|
+
"\n"+indent+" "+e.inspect
|
|
375
|
+
end
|
|
376
|
+
}.join("") :
|
|
377
|
+
""
|
|
378
|
+
)
|
|
379
|
+
end
|
|
380
|
+
end
|