logstash-lib 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,118 @@
|
|
1
|
+
---
|
2
|
+
title: ZeroMQ - logstash
|
3
|
+
layout: content_right
|
4
|
+
---
|
5
|
+
|
6
|
+
*ZeroMQ support in Logstash is currently in an experimental phase. As such, parts of this document are subject to change.*
|
7
|
+
|
8
|
+
# ZeroMQ
|
9
|
+
Simply put ZeroMQ (0mq) is a socket on steroids. This makes it a perfect compliment to Logstash - a pipe on steroids.
|
10
|
+
|
11
|
+
ZeroMQ allows you to easily create sockets of various types for moving data around. These sockets are refered to in ZeroMQ by the behavior of each side of the socket pair:
|
12
|
+
|
13
|
+
* PUSH/PULL
|
14
|
+
* REQ/REP
|
15
|
+
* PUB/SUB
|
16
|
+
* ROUTER/DEALER
|
17
|
+
|
18
|
+
There is also a `PAIR` socket type as well.
|
19
|
+
|
20
|
+
Additionally, the socket type is independent of the connection method. A PUB/SUB socket pair could have the SUB side of the socket be a listener and the PUB side a connecting client. This makes it very easy to fit ZeroMQ into various firewalled architectures.
|
21
|
+
|
22
|
+
Note that this is not a full-fledged tutorial on ZeroMQ. It is a tutorial on how Logstash uses ZeroMQ.
|
23
|
+
|
24
|
+
# ZeroMQ and logstash
|
25
|
+
In the spirit of ZeroMQ, Logstash takes these socket type pairs and uses them to create topologies with some very simply rules that make usage very easy to understand:
|
26
|
+
|
27
|
+
* The receiving end of a socket pair is always a logstash input
|
28
|
+
* The sending end of a socket pair is always a logstash output
|
29
|
+
* By default, inputs `bind`/listen and outputs `connect`
|
30
|
+
* Logstash refers to the socket pairs as topologies and mirrors the naming scheme from ZeroMQ
|
31
|
+
* By default, ZeroMQ inputs listen on all interfaces on port 2120, ZeroMQ outputs connect to `localhost` on port 2120
|
32
|
+
|
33
|
+
The currently understood Logstash topologies for ZeroMQ inputs and outputs are:
|
34
|
+
|
35
|
+
* `pushpull`
|
36
|
+
* `pubsub`
|
37
|
+
* `pair`
|
38
|
+
|
39
|
+
We have found from various discussions that these three topologies will cover most of user's needs. We hope to expose the full span of ZeroMQ socket types as time goes on.
|
40
|
+
|
41
|
+
By keeping the options simple, this allows you to get started VERY easily with what are normally complex message flows. No more confusion over `exchanges` and `queues` and `brokers`. If you need to add fanout capability to your flow, you can simply use the following configs:
|
42
|
+
|
43
|
+
* _node agent lives at 192.168.1.2_
|
44
|
+
* _indexer agent lives at 192.168.1.1_
|
45
|
+
|
46
|
+
# Node agent config
|
47
|
+
input { stdin { type => "test-stdin-input" } }
|
48
|
+
output { zeromq { topology => "pubsub" address => "tcp://192.168.1.1.:2120" } }
|
49
|
+
|
50
|
+
# Indexer agent config
|
51
|
+
input { zeromq { topology => "pubsub" } }
|
52
|
+
output { stdout { debug => true }}
|
53
|
+
|
54
|
+
If for some reason you need connections to initiate from the indexer because of firewall rules:
|
55
|
+
|
56
|
+
# Node agent config - now listening on all interfaces port 2120
|
57
|
+
input { stdin { type => "test-stdin-input" } }
|
58
|
+
output { zeromq { topology => "pubsub" address => "tcp://*.:2120" mode => "server" } }
|
59
|
+
|
60
|
+
# Indexer agent config
|
61
|
+
input { zeromq { topology => "pubsub" address => "tcp://192.168.1.2" mode => "client" } }
|
62
|
+
output { stdout { debug => true }}
|
63
|
+
|
64
|
+
As stated above, by default `inputs` always start as listeners and `outputs` always start as initiators. Please don't confuse what happens once the socket is connect with the direction of the connection. ZeroMQ separates connection from topology. In the second case of the above configs, once the two sockets are connected, regardless of who initiated the connection, the message flow itself is absolute. The indexer is reading events from the node.
|
65
|
+
|
66
|
+
# Which topology to use
|
67
|
+
The choice of topology can be broken down very easily based on need
|
68
|
+
|
69
|
+
## one to one
|
70
|
+
Use `pair` topology. On the output side, specify the ipaddress and port of the input side.
|
71
|
+
|
72
|
+
## broadcast
|
73
|
+
Use `pubsub`
|
74
|
+
If you need to broadcast ALL messages to multiple hosts that each need to see all events, use `pubsub`. Note that all events are broadcast to all subscribers. When using `pubsub` you might also want to investigate the `topic` configuration option which allows subscribers to see only a subset of messages.
|
75
|
+
|
76
|
+
## Filter workers
|
77
|
+
Use `pushpull`
|
78
|
+
In `pushpull`, ZeroMQ automatically load balances to all connected peers. This means that no peer sees the same message as any other peer.
|
79
|
+
|
80
|
+
# What's with the address format?
|
81
|
+
ZeroMQ supports multiple types of transports:
|
82
|
+
|
83
|
+
* inproc:// (unsupported by logstash due to threading)
|
84
|
+
* tcp:// (exactly what it sounds like)
|
85
|
+
* ipc:// (probably useless in logstash)
|
86
|
+
* pgm:// and epgm:// (a multicast format - only usable with PUB and SUB socket types)
|
87
|
+
|
88
|
+
For pretty much all cases, you'll be using `tcp://` transports with Logstash.
|
89
|
+
|
90
|
+
## Topic - applies to `pubsub`
|
91
|
+
This opt mimics the routing keys functionality in AMQP. Imagine you have a network of receivers but only a subset of the messages need to be seen by a subset of the hosts. You can use this option as a routing key to facilite that:
|
92
|
+
|
93
|
+
# This output is a PUB
|
94
|
+
output {
|
95
|
+
zeromq { topology => "pubsub" topic => "logs.production.%{host}" }
|
96
|
+
}
|
97
|
+
|
98
|
+
# This input is a SUB
|
99
|
+
# I only care about db1 logs
|
100
|
+
input { zeromq { type => "db1logs" address => "tcp://<ipaddress>:2120" topic => "logs.production.db1"}}
|
101
|
+
|
102
|
+
One thing important to note about 0mq PUBSUB and topics is that all filtering is done on the subscriber side. The subscriber will get ALL messages but discard any that don't match the topic.
|
103
|
+
|
104
|
+
Also important to note is that 0mq doesn't do topic in the same sense as an AMQP broker might. When a SUB socket gets a message, it compares the first bytes of the message against the topic. However, this isn't always flexible depending on the format of your message. The common practice then, is to send a 0mq multipart message and make the first part the topic. The next parts become the actual message body.
|
105
|
+
|
106
|
+
This is approach is how logstash handles this. When using PUBSUB, Logstash will send a multipart message where the first part is the name of the topic and the second part is the event. This is important to know if you are sending to a SUB input from sources other than Logstash.
|
107
|
+
|
108
|
+
# sockopts
|
109
|
+
Sockopts is not you choosing between blue or black socks. ZeroMQ supports setting various flags or options on sockets. In the interest of minimizing configuration syntax, these are _hidden_ behind a logstash configuration element called `sockopts`. You probably won't need to tune these for most cases. If you do need to tune them, you'll probably set the following:
|
110
|
+
|
111
|
+
## ZMQ::HWM - sets the high water mark
|
112
|
+
The high water mark is the maximum number of messages a given socket pair can have in its internal queue. Use this to throttle essentially.
|
113
|
+
|
114
|
+
## ZMQ::SWAP_SIZE
|
115
|
+
TODO
|
116
|
+
|
117
|
+
## ZMQ::IDENTITY
|
118
|
+
TODO
|
data/extract_services.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Extract META-INFO/services/* files from jars
|
2
|
+
#
|
3
|
+
require "optparse"
|
4
|
+
|
5
|
+
output = nil
|
6
|
+
|
7
|
+
flags = OptionParser.new do |opts|
|
8
|
+
opts.on("-o", "--output DIR",
|
9
|
+
"Where to write the merged META-INF/services/* files") do |dir|
|
10
|
+
output = dir
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
flags.parse!(ARGV)
|
15
|
+
|
16
|
+
ARGV.each do |jar|
|
17
|
+
# Find any files matching /META-INF/services/* in any jar given on the
|
18
|
+
# command line.
|
19
|
+
# Append all file content to the output directory with the same file name
|
20
|
+
# as is in the jar.
|
21
|
+
glob = "file:///#{File.expand_path(jar)}!/META-INF/services/*"
|
22
|
+
Dir.glob(glob).each do |service|
|
23
|
+
name = File.basename(service)
|
24
|
+
File.open(File.join(output, name), "a") do |fd|
|
25
|
+
puts "Adding #{name} from #{File.basename(jar)}"
|
26
|
+
fd.write(File.read(service))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/gembag.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rbconfig"
|
4
|
+
|
5
|
+
rubyabi = RbConfig::CONFIG["ruby_version"]
|
6
|
+
target = "#{Dir.pwd}/vendor/bundle"
|
7
|
+
gemdir = "#{target}/#{RUBY_ENGINE}/#{rubyabi}/"
|
8
|
+
ENV["GEM_HOME"] = gemdir
|
9
|
+
ENV["GEM_PATH"] = ""
|
10
|
+
|
11
|
+
require "rubygems/specification"
|
12
|
+
require "rubygems/commands/install_command"
|
13
|
+
|
14
|
+
def install_gem(name, requirement, target)
|
15
|
+
puts "Fetching and installing gem: #{name} (#{requirement})"
|
16
|
+
|
17
|
+
installer = Gem::Commands::InstallCommand.new
|
18
|
+
installer.options[:generate_rdoc] = false
|
19
|
+
installer.options[:generate_ri] = false
|
20
|
+
installer.options[:version] = requirement
|
21
|
+
installer.options[:args] = [name]
|
22
|
+
installer.options[:install_dir] = target
|
23
|
+
|
24
|
+
# ruby 2.0.0 / rubygems 2.x; disable documentation generation
|
25
|
+
installer.options[:document] = []
|
26
|
+
begin
|
27
|
+
installer.execute
|
28
|
+
rescue Gem::SystemExitException => e
|
29
|
+
if e.exit_code != 0
|
30
|
+
puts "Installation of #{name} failed"
|
31
|
+
raise
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end # def install_gem
|
35
|
+
|
36
|
+
# Ensure bundler is available.
|
37
|
+
begin
|
38
|
+
gem("bundler", ">=1.3.5")
|
39
|
+
rescue Gem::LoadError => e
|
40
|
+
install_gem("bundler", ">= 1.3.5", ENV["GEM_HOME"])
|
41
|
+
end
|
42
|
+
|
43
|
+
require "bundler/cli"
|
44
|
+
|
45
|
+
# Monkeypatch bundler to write a .lock file specific to the version of ruby.
|
46
|
+
# This keeps MRI/JRuby/RBX from conflicting over the Gemfile.lock updates
|
47
|
+
module Bundler
|
48
|
+
module SharedHelpers
|
49
|
+
def default_lockfile
|
50
|
+
ruby = "#{RUBY_ENGINE}-#{RbConfig::CONFIG["ruby_version"]}"
|
51
|
+
return Pathname.new("#{default_gemfile}.#{ruby}.lock")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if RUBY_ENGINE == "rbx"
|
57
|
+
begin
|
58
|
+
gem("rubysl")
|
59
|
+
rescue Gem::LoadError => e
|
60
|
+
install_gem("rubysl", ">= 0", ENV["GEM_HOME"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
Bundler::CLI.start(["install", "--gemfile=tools/Gemfile", "--path", target, "--clean", "--jobs", "4"])
|
data/lib/logstash.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# TODO(sissel): require "openssl" takes *ages* from the logstash jar
|
3
|
+
# TODO(sissel): monkeypatch Kernel.require to apply this monkeypatch only after
|
4
|
+
# a 'require "openssl" has occurred.
|
5
|
+
class OpenSSL::SSL::SSLContext
|
6
|
+
alias_method :ca_path_JRUBY_6970=, :ca_path=
|
7
|
+
alias_method :ca_file_JRUBY_6970=, :ca_file=
|
8
|
+
|
9
|
+
def ca_file=(arg)
|
10
|
+
if arg =~ /^jar:file:\//
|
11
|
+
return ca_file_JRUBY_6970=(arg.gsub(/^jar:/, ""))
|
12
|
+
end
|
13
|
+
return ca_file_JRUBY_6970=(arg)
|
14
|
+
end
|
15
|
+
|
16
|
+
def ca_path=(arg)
|
17
|
+
if arg =~ /^jar:file:\//
|
18
|
+
return ca_path_JRUBY_6970=(arg.gsub(/^jar:/, ""))
|
19
|
+
end
|
20
|
+
return ca_path_JRUBY_6970=(arg)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Monkeypatch for JRUBY-6970
|
3
|
+
module Kernel
|
4
|
+
alias_method :require_JRUBY_6970_hack, :require
|
5
|
+
|
6
|
+
def require(path)
|
7
|
+
old_load_path = nil
|
8
|
+
|
9
|
+
if path =~ /^jar:file:.+!.+/
|
10
|
+
path = path.gsub(/^jar:/, "")
|
11
|
+
puts "JRUBY-6970: require(#{path})" if ENV["REQUIRE_DEBUG"] == "1"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Work around slow openssl load times in flatjar. (LOGSTASH-1223)
|
15
|
+
# I don't know why this works, I don't care either. This problem only
|
16
|
+
# exists in the 'jar' builds of logstash which are going to be going away
|
17
|
+
# soon in favor of the much-better tarball/zip releases!
|
18
|
+
if __FILE__ =~ /^(?:jar:)?file:.+!.+/ && path == "openssl"
|
19
|
+
# Loading shared/jruby-openssl first seems to make openssl load faster
|
20
|
+
# I have no idea. Computers.
|
21
|
+
require_JRUBY_6970_hack "shared/jruby-openssl"
|
22
|
+
return require_JRUBY_6970_hack "openssl"
|
23
|
+
end
|
24
|
+
|
25
|
+
# JRUBY-7065
|
26
|
+
path = File.expand_path(path) if path.include?("/../")
|
27
|
+
rc = require_JRUBY_6970_hack(path)
|
28
|
+
|
29
|
+
# Only monkeypatch openssl after it's been loaded.
|
30
|
+
if path == "openssl"
|
31
|
+
require "logstash/JRUBY-6970-openssl"
|
32
|
+
end
|
33
|
+
return rc
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Work around for a bug in File.expand_path that doesn't account for resources
|
38
|
+
# in jar paths.
|
39
|
+
#
|
40
|
+
# Should solve this error:
|
41
|
+
# Exception in thread "LogStash::Runner" org.jruby.exceptions.RaiseException:
|
42
|
+
# (Errno::ENOENT) file:/home/jls/projects/logstash/build/data/unicode.data
|
43
|
+
class File
|
44
|
+
class << self
|
45
|
+
alias_method :expand_path_JRUBY_6970, :expand_path
|
46
|
+
|
47
|
+
def expand_path(path, dir=nil)
|
48
|
+
#p :expand_path => [path, dir]
|
49
|
+
if path =~ /(jar:)?file:\/.*\.jar!/
|
50
|
+
#p :expand_path_path => [path, dir]
|
51
|
+
jar, resource = path.split("!", 2)
|
52
|
+
#p :expand_path => [jar, resource]
|
53
|
+
if resource.nil? || resource == ""
|
54
|
+
# Nothing after the "!", nothing special to handle.
|
55
|
+
return expand_path_JRUBY_6970(path, dir)
|
56
|
+
else
|
57
|
+
resource = expand_path_JRUBY_6970(resource, dir)
|
58
|
+
return fix_jar_path(jar, resource)
|
59
|
+
end
|
60
|
+
elsif dir =~ /(jar:)?file:\/.*\.jar!/
|
61
|
+
jar, dir = dir.split("!", 2)
|
62
|
+
if dir.empty?
|
63
|
+
# sometimes the original dir is just 'file:/foo.jar!'
|
64
|
+
return File.join("#{jar}!", path)
|
65
|
+
end
|
66
|
+
dir = expand_path_JRUBY_6970(path, dir)
|
67
|
+
return fix_jar_path(jar, dir)
|
68
|
+
else
|
69
|
+
return expand_path_JRUBY_6970(path, dir)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
protected
|
75
|
+
|
76
|
+
def self.fix_jar_path(jar, resource)
|
77
|
+
# TODO(sissel): use LogStash::Util::UNAME
|
78
|
+
if RbConfig::CONFIG["host_os"] == "mswin32"
|
79
|
+
# 'expand_path' on "/" will return "C:/" on windows.
|
80
|
+
# So like.. we don't want that because technically this
|
81
|
+
# is the root of the jar, not of a disk.
|
82
|
+
#puts :fix_jar_path => ["#{jar}!#{resource.gsub(/^[A-Za-z]:/, "")}"]
|
83
|
+
return "#{jar}!#{resource.gsub(/^[A-Za-z]:/, "")}"
|
84
|
+
else
|
85
|
+
return "#{jar}!#{resource}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Dir
|
91
|
+
class << self
|
92
|
+
alias_method :glob_JRUBY_6970_hack, :glob
|
93
|
+
def glob(path, flags=nil)
|
94
|
+
if path =~ /^jar:file:/
|
95
|
+
# Strip leading 'jar:' (LOGSTASH-1316)
|
96
|
+
return glob_JRUBY_6970_hack(path.gsub(/^jar:/, ""))
|
97
|
+
else
|
98
|
+
return glob_JRUBY_6970_hack(path)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,305 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "clamp" # gem 'clamp'
|
3
|
+
require "logstash/errors"
|
4
|
+
require "i18n"
|
5
|
+
|
6
|
+
class LogStash::Agent < Clamp::Command
|
7
|
+
option ["-f", "--config"], "CONFIG_PATH",
|
8
|
+
I18n.t("logstash.agent.flag.config"),
|
9
|
+
:attribute_name => :config_path
|
10
|
+
|
11
|
+
option "-e", "CONFIG_STRING",
|
12
|
+
I18n.t("logstash.agent.flag.config-string"),
|
13
|
+
:attribute_name => :config_string
|
14
|
+
|
15
|
+
option ["-w", "--filterworkers"], "COUNT",
|
16
|
+
I18n.t("logstash.agent.flag.filterworkers"),
|
17
|
+
:attribute_name => :filter_workers, :default => 1, &:to_i
|
18
|
+
|
19
|
+
option "--watchdog-timeout", "SECONDS",
|
20
|
+
I18n.t("logstash.agent.flag.watchdog-timeout"),
|
21
|
+
:default => 10, &:to_f
|
22
|
+
|
23
|
+
option ["-l", "--log"], "FILE",
|
24
|
+
I18n.t("logstash.agent.flag.log"),
|
25
|
+
:attribute_name => :log_file
|
26
|
+
|
27
|
+
# Old support for the '-v' flag'
|
28
|
+
option "-v", :flag,
|
29
|
+
I18n.t("logstash.agent.flag.verbosity"),
|
30
|
+
:attribute_name => :verbosity, :multivalued => true
|
31
|
+
|
32
|
+
option "--quiet", :flag, I18n.t("logstash.agent.flag.quiet")
|
33
|
+
option "--verbose", :flag, I18n.t("logstash.agent.flag.verbose")
|
34
|
+
option "--debug", :flag, I18n.t("logstash.agent.flag.debug")
|
35
|
+
|
36
|
+
option ["-V", "--version"], :flag,
|
37
|
+
I18n.t("logstash.agent.flag.version")
|
38
|
+
|
39
|
+
option ["-p", "--pluginpath"] , "PATH",
|
40
|
+
I18n.t("logstash.agent.flag.pluginpath"),
|
41
|
+
:multivalued => true,
|
42
|
+
:attribute_name => :plugin_paths
|
43
|
+
|
44
|
+
option ["-t", "--configtest"], :flag,
|
45
|
+
I18n.t("logstash.agent.flag.configtest"),
|
46
|
+
:attribute_name => :config_test
|
47
|
+
|
48
|
+
# Emit a warning message.
|
49
|
+
def warn(message)
|
50
|
+
# For now, all warnings are fatal.
|
51
|
+
raise LogStash::ConfigurationError, message
|
52
|
+
end # def warn
|
53
|
+
|
54
|
+
# Emit a failure message and abort.
|
55
|
+
def fail(message)
|
56
|
+
raise LogStash::ConfigurationError, message
|
57
|
+
end # def fail
|
58
|
+
|
59
|
+
def report(message)
|
60
|
+
# Print to stdout just in case we're logging to a file
|
61
|
+
puts message
|
62
|
+
@logger.log(message) if log_file
|
63
|
+
end
|
64
|
+
|
65
|
+
# Run the agent. This method is invoked after clamp parses the
|
66
|
+
# flags given to this program.
|
67
|
+
def execute
|
68
|
+
require "logstash/pipeline"
|
69
|
+
require "cabin" # gem 'cabin'
|
70
|
+
require "logstash/plugin"
|
71
|
+
@logger = Cabin::Channel.get(LogStash)
|
72
|
+
|
73
|
+
if version?
|
74
|
+
show_version
|
75
|
+
return 0
|
76
|
+
end
|
77
|
+
|
78
|
+
# temporarily send logs to stdout as well if a --log is specified
|
79
|
+
# and stdout appears to be a tty
|
80
|
+
show_startup_errors = log_file && STDOUT.tty?
|
81
|
+
|
82
|
+
if show_startup_errors
|
83
|
+
stdout_logs = @logger.subscribe(STDOUT)
|
84
|
+
end
|
85
|
+
configure
|
86
|
+
|
87
|
+
# You must specify a config_string or config_path
|
88
|
+
if config_string.nil? && config_path.nil?
|
89
|
+
fail(help + "\n" + I18n.t("logstash.agent.missing-configuration"))
|
90
|
+
end
|
91
|
+
|
92
|
+
if @config_path
|
93
|
+
@config_string = load_config(@config_path)
|
94
|
+
else
|
95
|
+
# include a default stdin input if no inputs given
|
96
|
+
if @config_string !~ /input *{/
|
97
|
+
@config_string += "input { stdin { type => stdin } }"
|
98
|
+
end
|
99
|
+
# include a default stdout output if no outputs given
|
100
|
+
if @config_string !~ /output *{/
|
101
|
+
@config_string += "output { stdout { codec => rubydebug } }"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
begin
|
106
|
+
pipeline = LogStash::Pipeline.new(@config_string)
|
107
|
+
rescue LoadError => e
|
108
|
+
fail("Configuration problem.")
|
109
|
+
end
|
110
|
+
|
111
|
+
# Stop now if we are only asking for a config test.
|
112
|
+
if config_test?
|
113
|
+
report "Configuration OK"
|
114
|
+
return
|
115
|
+
end
|
116
|
+
|
117
|
+
# Make SIGINT shutdown the pipeline.
|
118
|
+
trap_id = Stud::trap("INT") do
|
119
|
+
@logger.warn(I18n.t("logstash.agent.interrupted"))
|
120
|
+
pipeline.shutdown
|
121
|
+
end
|
122
|
+
|
123
|
+
Stud::trap("HUP") do
|
124
|
+
@logger.info(I18n.t("logstash.agent.sighup"))
|
125
|
+
configure_logging(log_file)
|
126
|
+
end
|
127
|
+
|
128
|
+
pipeline.configure("filter-workers", filter_workers)
|
129
|
+
|
130
|
+
@logger.unsubscribe(stdout_logs) if show_startup_errors
|
131
|
+
|
132
|
+
# TODO(sissel): Get pipeline completion status.
|
133
|
+
pipeline.run
|
134
|
+
return 0
|
135
|
+
rescue LogStash::ConfigurationError => e
|
136
|
+
@logger.unsubscribe(stdout_logs) if show_startup_errors
|
137
|
+
report I18n.t("logstash.agent.error", :error => e)
|
138
|
+
return 1
|
139
|
+
rescue => e
|
140
|
+
@logger.unsubscribe(stdout_logs) if show_startup_errors
|
141
|
+
report I18n.t("oops", :error => e)
|
142
|
+
report e.backtrace if @logger.debug? || $DEBUGLIST.include?("stacktrace")
|
143
|
+
return 1
|
144
|
+
ensure
|
145
|
+
@log_fd.close if @log_fd
|
146
|
+
Stud::untrap("INT", trap_id) unless trap_id.nil?
|
147
|
+
end # def execute
|
148
|
+
|
149
|
+
def show_version
|
150
|
+
show_version_logstash
|
151
|
+
|
152
|
+
if [:info, :debug].include?(verbosity?) || debug? || verbose?
|
153
|
+
show_version_ruby
|
154
|
+
|
155
|
+
if RUBY_PLATFORM == "java"
|
156
|
+
show_version_java
|
157
|
+
show_version_elasticsearch
|
158
|
+
end
|
159
|
+
|
160
|
+
if [:debug].include?(verbosity?) || debug?
|
161
|
+
show_gems
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end # def show_version
|
165
|
+
|
166
|
+
def show_version_logstash
|
167
|
+
require "logstash/version"
|
168
|
+
puts "logstash #{LOGSTASH_VERSION}"
|
169
|
+
end # def show_version_logstash
|
170
|
+
|
171
|
+
def show_version_ruby
|
172
|
+
puts RUBY_DESCRIPTION
|
173
|
+
end # def show_version_ruby
|
174
|
+
|
175
|
+
def show_version_elasticsearch
|
176
|
+
# Not running in the,jar? assume elasticsearch jars are
|
177
|
+
# in ../../vendor/jar/...
|
178
|
+
if __FILE__ !~ /^(?:jar:)?file:/
|
179
|
+
jarpath = File.join(File.dirname(__FILE__), "../../vendor/jar/elasticsearch*/lib/*.jar")
|
180
|
+
Dir.glob(jarpath).each do |jar|
|
181
|
+
require jar
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
$stdout.write("Elasticsearch: ");
|
186
|
+
org.elasticsearch.Version::main([])
|
187
|
+
end # def show_version_elasticsearch
|
188
|
+
|
189
|
+
def show_version_java
|
190
|
+
properties = java.lang.System.getProperties
|
191
|
+
puts "java #{properties["java.version"]} (#{properties["java.vendor"]})"
|
192
|
+
puts "jvm #{properties["java.vm.name"]} / #{properties["java.vm.version"]}"
|
193
|
+
end # def show_version_java
|
194
|
+
|
195
|
+
def show_gems
|
196
|
+
require "rubygems"
|
197
|
+
Gem::Specification.each do |spec|
|
198
|
+
puts "gem #{spec.name} #{spec.version}"
|
199
|
+
end
|
200
|
+
end # def show_gems
|
201
|
+
|
202
|
+
# Do any start-time configuration.
|
203
|
+
#
|
204
|
+
# Log file stuff, plugin path checking, etc.
|
205
|
+
def configure
|
206
|
+
configure_logging(log_file)
|
207
|
+
configure_plugin_path(plugin_paths) if !plugin_paths.nil?
|
208
|
+
end # def configure
|
209
|
+
|
210
|
+
# Point logging at a specific path.
|
211
|
+
def configure_logging(path)
|
212
|
+
# Set with the -v (or -vv...) flag
|
213
|
+
if quiet?
|
214
|
+
@logger.level = :error
|
215
|
+
elsif verbose?
|
216
|
+
@logger.level = :info
|
217
|
+
elsif debug?
|
218
|
+
@logger.level = :debug
|
219
|
+
else
|
220
|
+
# Old support for the -v and -vv stuff.
|
221
|
+
if verbosity? && verbosity?.any?
|
222
|
+
# this is an array with length of how many times the flag is given
|
223
|
+
if verbosity?.length == 1
|
224
|
+
@logger.warn("The -v flag is deprecated and will be removed in a future release. You should use --verbose instead.")
|
225
|
+
@logger.level = :info
|
226
|
+
else
|
227
|
+
@logger.warn("The -vv flag is deprecated and will be removed in a future release. You should use --debug instead.")
|
228
|
+
@logger.level = :debug
|
229
|
+
end
|
230
|
+
else
|
231
|
+
@logger.level = :warn
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
if log_file
|
237
|
+
# TODO(sissel): Implement file output/rotation in Cabin.
|
238
|
+
# TODO(sissel): Catch exceptions, report sane errors.
|
239
|
+
begin
|
240
|
+
@log_fd.close if @log_fd
|
241
|
+
@log_fd = File.new(path, "a")
|
242
|
+
rescue => e
|
243
|
+
fail(I18n.t("logstash.agent.configuration.log_file_failed",
|
244
|
+
:path => path, :error => e))
|
245
|
+
end
|
246
|
+
|
247
|
+
puts "Sending logstash logs to #{path}."
|
248
|
+
@logger.unsubscribe(@logger_subscription) if @logger_subscription
|
249
|
+
@logger_subscription = @logger.subscribe(@log_fd)
|
250
|
+
else
|
251
|
+
@logger.subscribe(STDOUT)
|
252
|
+
end
|
253
|
+
|
254
|
+
# TODO(sissel): redirect stdout/stderr to the log as well
|
255
|
+
# http://jira.codehaus.org/browse/JRUBY-7003
|
256
|
+
end # def configure_logging
|
257
|
+
|
258
|
+
# Validate and add any paths to the list of locations
|
259
|
+
# logstash will look to find plugins.
|
260
|
+
def configure_plugin_path(paths)
|
261
|
+
# Append any plugin paths to the ruby search path
|
262
|
+
paths.each do |path|
|
263
|
+
# Verify the path exists
|
264
|
+
if !Dir.exists?(path)
|
265
|
+
warn(I18n.t("logstash.agent.configuration.plugin_path_missing",
|
266
|
+
:path => path))
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
# TODO(sissel): Verify the path looks like the correct form.
|
271
|
+
# aka, there must be file in path/logstash/{filters,inputs,outputs}/*.rb
|
272
|
+
plugin_glob = File.join(path, "logstash", "{inputs,filters,outputs}", "*.rb")
|
273
|
+
if Dir.glob(plugin_glob).empty?
|
274
|
+
warn(I18n.t("logstash.agent.configuration.no_plugins_found",
|
275
|
+
:path => path, :plugin_glob => plugin_glob))
|
276
|
+
end
|
277
|
+
|
278
|
+
# We push plugin paths to the front of the LOAD_PATH so that folks
|
279
|
+
# can override any core logstash plugins if they need to.
|
280
|
+
@logger.debug("Adding plugin path", :path => path)
|
281
|
+
$LOAD_PATH.unshift(path)
|
282
|
+
end
|
283
|
+
end # def configure_plugin_path
|
284
|
+
|
285
|
+
def load_config(path)
|
286
|
+
path = File.join(path, "*") if File.directory?(path)
|
287
|
+
|
288
|
+
if Dir.glob(path).length == 0
|
289
|
+
fail(I18n.t("logstash.agent.configuration.file-not-found", :path => path))
|
290
|
+
end
|
291
|
+
|
292
|
+
config = ""
|
293
|
+
Dir.glob(path).sort.each do |file|
|
294
|
+
next unless File.file?(file)
|
295
|
+
if file.match(/~$/)
|
296
|
+
@logger.debug("NOT reading config file because it is a temp file", :file => file)
|
297
|
+
next
|
298
|
+
end
|
299
|
+
@logger.debug("Reading config file", :file => file)
|
300
|
+
config << File.read(file) + "\n"
|
301
|
+
end
|
302
|
+
return config
|
303
|
+
end # def load_config
|
304
|
+
|
305
|
+
end # class LogStash::Agent
|