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
data/README.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# logstash
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/logstash/logstash.png)](http://travis-ci.org/logstash/logstash)
|
4
|
+
|
5
|
+
logstash is a tool for managing events and logs. You can use it to collect
|
6
|
+
logs, parse them, and store them for later use (like, for searching). Speaking
|
7
|
+
of searching, logstash comes with a web interface for searching and drilling
|
8
|
+
into all of your logs.
|
9
|
+
|
10
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you
|
11
|
+
are pretty much free to use it however you want in whatever way.
|
12
|
+
|
13
|
+
For more info, see <http://logstash.net/>
|
14
|
+
|
15
|
+
## Need Help?
|
16
|
+
|
17
|
+
Need help? Try #logstash on freenode irc or the logstash-users@googlegroups.com
|
18
|
+
mailing list.
|
19
|
+
|
20
|
+
You can also find documentation on the <http://logstash.net> site.
|
21
|
+
|
22
|
+
## Developing
|
23
|
+
|
24
|
+
If you don't have JRuby already (or don't use rvm, rbenv, etc), you can have `bin/logstash` fetch it for you by setting `USE_JRUBY`:
|
25
|
+
|
26
|
+
USE_JRUBY=1 bin/logstash ...
|
27
|
+
|
28
|
+
Otherwise, here's how to get started with rvm:
|
29
|
+
|
30
|
+
# Install JRuby with rvm
|
31
|
+
rvm install jruby-1.7.8
|
32
|
+
rvm use jruby-1.7.8
|
33
|
+
|
34
|
+
Now install dependencies:
|
35
|
+
|
36
|
+
# Install logstash ruby dependencies
|
37
|
+
bin/logstash deps
|
38
|
+
|
39
|
+
Other commands:
|
40
|
+
|
41
|
+
# to use logstash gems or libraries in irb, use the following
|
42
|
+
# this gets you an 'irb' shell with logstash's environment
|
43
|
+
bin/logstash irb
|
44
|
+
|
45
|
+
# or use irb from the jar
|
46
|
+
java -jar logstash-<version>-monolithic.jar irb
|
47
|
+
|
48
|
+
# Run logstash
|
49
|
+
bin/logstash agent [options]
|
50
|
+
|
51
|
+
# If running bin/logstash agent yields complaints about log4j/other things
|
52
|
+
# This will download the elasticsearch jars so logstash can use them.
|
53
|
+
make vendor-elasticsearch
|
54
|
+
|
55
|
+
## Testing
|
56
|
+
|
57
|
+
There are a few ways to run the tests. For development, using `bin/logstash
|
58
|
+
rspec <some spec>` will suffice:
|
59
|
+
|
60
|
+
% bin/logstash rspec spec/filters/grok.rb
|
61
|
+
...................
|
62
|
+
|
63
|
+
Finished in 0.123 seconds
|
64
|
+
19 examples, 0 failures
|
65
|
+
|
66
|
+
Alternately, if you have just built the flatjar, you can run the tests
|
67
|
+
specifically on those like so:
|
68
|
+
|
69
|
+
make flatjar-test
|
70
|
+
|
71
|
+
If you want to run all the tests from source (not compiled jar), do:
|
72
|
+
|
73
|
+
make test
|
74
|
+
|
75
|
+
Finally, like 'bin/logstash rspec' above, you can invoke the jar to run a
|
76
|
+
specific test like so:
|
77
|
+
|
78
|
+
% java -jar logstash.jar rspec spec/filters/grok.rb
|
79
|
+
...................
|
80
|
+
|
81
|
+
Finished in 0.346 seconds
|
82
|
+
19 examples, 0 failures
|
83
|
+
|
84
|
+
## Building
|
85
|
+
|
86
|
+
Building is not required. You are highly recommended to download the releases
|
87
|
+
we provide from the logstash site!
|
88
|
+
|
89
|
+
If you want to build the jar yourself, run:
|
90
|
+
|
91
|
+
make flatjar
|
92
|
+
|
93
|
+
To update a flat jar previously built with 'make flatjar', run:
|
94
|
+
|
95
|
+
make update-flatjar
|
96
|
+
|
97
|
+
|
98
|
+
You can build rpms and debs, if you need those. Building rpms requires you have [fpm](github.com/jordansissel/fpm), then do this:
|
99
|
+
|
100
|
+
make package
|
101
|
+
|
102
|
+
## Project Principles
|
103
|
+
|
104
|
+
* Community: If a newbie has a bad time, it's a bug.
|
105
|
+
* Software: Make it work, then make it right, then make it fast.
|
106
|
+
* Technology: If it doesn't do a thing today, we can make it do it tomorrow.
|
107
|
+
|
108
|
+
## Contributing
|
109
|
+
|
110
|
+
All contributions are welcome: ideas, patches, documentation, bug reports,
|
111
|
+
complaints, and even something you drew up on a napkin.
|
112
|
+
|
113
|
+
Programming is not a required skill. Whatever you've seen about open source and
|
114
|
+
maintainers or community members saying "send patches or die" - you will not
|
115
|
+
see that here.
|
116
|
+
|
117
|
+
It is more important to me that you are able to contribute.
|
118
|
+
|
119
|
+
For more information about contributing, see the
|
120
|
+
[CONTRIBUTING](CONTRIBUTING.md) file.
|
data/STYLE.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Style Guide
|
2
|
+
|
3
|
+
Rather than write a full style guide, please follow by examples you see in the
|
4
|
+
code. If you send me a patch, I will not reject it for style reasons (but I
|
5
|
+
will fix it before it gets committed).
|
6
|
+
|
7
|
+
## Logging
|
8
|
+
|
9
|
+
We support logging structured data, so please do that.
|
10
|
+
|
11
|
+
Rather than this:
|
12
|
+
|
13
|
+
@logger.info("Some error occured in request #{request} on input #{input} from client #{ip}")
|
14
|
+
|
15
|
+
Do this:
|
16
|
+
|
17
|
+
@logger.info("Some error occured in this request", :request => request, :input => input, :client => ip)
|
18
|
+
|
19
|
+
## Code Style
|
20
|
+
|
21
|
+
* comment everything you can think of.
|
22
|
+
* indentation: 2 spaces
|
23
|
+
* between methods: 1 line
|
24
|
+
* sort your requires
|
25
|
+
* long lines should wrap at 80 characters. If you wrap at an operator ('or',
|
26
|
+
'+', etc) start the next line with that operator.
|
27
|
+
* parentheses on function definitions/calls
|
28
|
+
* explicit is better than implicit
|
29
|
+
* implicit returns are forbidden except in the case of a single expression
|
30
|
+
|
31
|
+
The point is consistency and documentation. If you see inconsistencies, let me
|
32
|
+
know, and I'll fix them :)
|
33
|
+
|
34
|
+
Short example:
|
35
|
+
|
36
|
+
require "something from a gem" # from gem 'thing'
|
37
|
+
|
38
|
+
# some documentation about this class
|
39
|
+
class Foo < Bar
|
40
|
+
# some documentation about this function
|
41
|
+
def somefunc(arg1, arg2, arg3)
|
42
|
+
# comment
|
43
|
+
puts "Hello"
|
44
|
+
if (some_long_condition \
|
45
|
+
or some_other_condition)
|
46
|
+
puts "World"
|
47
|
+
end # if <very short description>
|
48
|
+
|
49
|
+
# Long lines should wrap and start with an operator if possible.
|
50
|
+
foo = some + long + formula + thing \
|
51
|
+
+ stuff + bar;
|
52
|
+
|
53
|
+
# Function calls, when wrapping, should align to the '(' where reasonable.
|
54
|
+
some_function_call(arg1, arg2, arg3, some_long_thing,
|
55
|
+
alignment_here, arg6)
|
56
|
+
# If it seems unreasonable, wrap and indent 4 spaces.
|
57
|
+
some_really_long_function_call_blah_blah_blah(arg1,
|
58
|
+
arg2, arg3, arg4)
|
59
|
+
|
60
|
+
# indent the 'when' inside a 'case'.
|
61
|
+
case foo
|
62
|
+
when "bar"
|
63
|
+
puts "Hello world"
|
64
|
+
when /testing/
|
65
|
+
puts "testing
|
66
|
+
else
|
67
|
+
puts "I got nothin'"
|
68
|
+
end # case foo
|
69
|
+
|
70
|
+
end # def somefunc
|
71
|
+
end # class Foo
|
72
|
+
|
73
|
+
## Specific cases
|
74
|
+
|
75
|
+
### Hash Syntax
|
76
|
+
|
77
|
+
Use of the "hash colon" syntax (ruby 1.9) is not accepted.
|
78
|
+
|
79
|
+
# This is NOT good.
|
80
|
+
{ foo: "bar" }
|
81
|
+
|
82
|
+
# This is good.
|
83
|
+
{ :foo => "bar" }
|
84
|
+
|
85
|
+
### String#[]
|
86
|
+
|
87
|
+
String#[] with one numeric argument must not be used due to bugs and
|
88
|
+
inconsistencies between ruby versions.
|
89
|
+
|
90
|
+
str = "foo"
|
91
|
+
|
92
|
+
# This is NOT good
|
93
|
+
str[0]
|
94
|
+
|
95
|
+
# This is good.
|
96
|
+
str[0, 1]
|
data/bin/logstash
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Run logstash from source
|
3
|
+
#
|
4
|
+
# This is most useful when done from a git checkout.
|
5
|
+
#
|
6
|
+
# Usage:
|
7
|
+
# bin/logstash <command> [arguments]
|
8
|
+
#
|
9
|
+
# See 'bin/logstash help' for a list of commands.
|
10
|
+
#
|
11
|
+
# NOTE: One extra command is available 'deps'
|
12
|
+
# The 'deps' command will install dependencies for logstash.
|
13
|
+
#
|
14
|
+
# If you do not have ruby installed, you can set "USE_JRUBY=1"
|
15
|
+
# in your environment and this script will download and use
|
16
|
+
# a release of JRuby for you.
|
17
|
+
|
18
|
+
# Defaults you can override with environment variables
|
19
|
+
LS_HEAP_SIZE="${LS_HEAP_SIZE:=500m}"
|
20
|
+
|
21
|
+
basedir=$(cd `dirname $0`/..; pwd)
|
22
|
+
. ${basedir}/bin/logstash.lib.sh
|
23
|
+
|
24
|
+
setup
|
25
|
+
|
26
|
+
case $1 in
|
27
|
+
deps) install_deps ;;
|
28
|
+
-*)
|
29
|
+
# is the first argument a flag? If so, assume 'agent'
|
30
|
+
program="$basedir/lib/logstash/runner.rb"
|
31
|
+
exec $RUBYCMD "$program" agent "$@"
|
32
|
+
;;
|
33
|
+
*)
|
34
|
+
program="$basedir/lib/logstash/runner.rb"
|
35
|
+
exec $RUBYCMD "$program" "$@"
|
36
|
+
;;
|
37
|
+
esac
|
data/bin/logstash-test
ADDED
data/bin/logstash-web
ADDED
data/bin/logstash.lib.sh
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
basedir=$(cd `dirname $0`/..; pwd)
|
2
|
+
|
3
|
+
setup_ruby() {
|
4
|
+
# Verify ruby works
|
5
|
+
if ! ruby -e 'puts "HURRAY"' 2> /dev/null | grep -q "HURRAY" ; then
|
6
|
+
echo "No ruby program found. Cannot start."
|
7
|
+
exit 1
|
8
|
+
fi
|
9
|
+
|
10
|
+
eval $(ruby -rrbconfig -e 'puts "RUBYVER=#{RbConfig::CONFIG["ruby_version"]}"; puts "RUBY=#{RUBY_ENGINE}"')
|
11
|
+
RUBYCMD="ruby"
|
12
|
+
}
|
13
|
+
|
14
|
+
setup_java() {
|
15
|
+
if [ -z "$JAVA_HOME/bin/java" ] ; then
|
16
|
+
JAVA="$JAVA_HOME/bin/java"
|
17
|
+
else
|
18
|
+
JAVA=$(which java)
|
19
|
+
fi
|
20
|
+
|
21
|
+
if [ ! -x "$JAVA" ] ; then
|
22
|
+
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME."
|
23
|
+
exit 1
|
24
|
+
fi
|
25
|
+
|
26
|
+
|
27
|
+
JAVA_OPTS="$JAVA_OPTS -Xmx${LS_HEAP_SIZE}"
|
28
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
|
29
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
|
30
|
+
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
|
31
|
+
|
32
|
+
JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
|
33
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
|
34
|
+
|
35
|
+
if [ ! -z "$LS_USE_GC_LOGGING" ] ; then
|
36
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
|
37
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps"
|
38
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram"
|
39
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution"
|
40
|
+
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"
|
41
|
+
JAVA_OPTS="$JAVA_OPTS -Xloggc:./logstash-gc.log"
|
42
|
+
echo "Writing garbage collection logs to ./logstash-gc.log"
|
43
|
+
fi
|
44
|
+
}
|
45
|
+
|
46
|
+
setup_vendored_jruby() {
|
47
|
+
RUBYVER=1.9
|
48
|
+
RUBY=jruby
|
49
|
+
|
50
|
+
setup_java
|
51
|
+
|
52
|
+
RUBYCMD="$JAVA $JAVA_OPTS -jar $basedir/vendor/jar/jruby-complete-*.jar"
|
53
|
+
}
|
54
|
+
|
55
|
+
setup() {
|
56
|
+
if [ -z "$USE_JRUBY" -a \( -d "$basedir/.git" -o ! -z "$USE_RUBY" \) ] ; then
|
57
|
+
setup_ruby
|
58
|
+
if [ "$RUBY" = "jruby" ] ; then
|
59
|
+
setup_java
|
60
|
+
export JAVA_OPTS
|
61
|
+
fi
|
62
|
+
else
|
63
|
+
setup_vendored_jruby
|
64
|
+
fi
|
65
|
+
export GEM_HOME="$basedir/vendor/bundle/${RUBY}/${RUBYVER}"
|
66
|
+
export GEM_PATH=
|
67
|
+
export RUBYLIB="$basedir/lib"
|
68
|
+
}
|
69
|
+
|
70
|
+
install_deps() {
|
71
|
+
if [ -f "$basedir/logstash.gemspec" ] ; then
|
72
|
+
program="$basedir/gembag.rb"
|
73
|
+
set -- "$basedir/logstash.gemspec"
|
74
|
+
exec $RUBYCMD "$basedir/gembag.rb" "$@"
|
75
|
+
else
|
76
|
+
echo "Cannot install dependencies; missing logstash.gemspec. This 'deps' command only works from a logstash git clone."
|
77
|
+
fi
|
78
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "octokit"
|
2
|
+
##
|
3
|
+
# This script will validate that any pull request submitted against a github
|
4
|
+
# repository will contains changes to CHANGELOG file.
|
5
|
+
#
|
6
|
+
# If not the case, an helpful text will be commented on the pull request
|
7
|
+
# If ok, a thanksful message will be commented also containing a @mention to
|
8
|
+
# acts as a trigger for review notification by a human.
|
9
|
+
##
|
10
|
+
|
11
|
+
|
12
|
+
@bot="" # Put here your bot github username
|
13
|
+
@password="" # Put here your bot github password
|
14
|
+
|
15
|
+
@repository="logstash/logstash"
|
16
|
+
@mention="@jordansissel"
|
17
|
+
|
18
|
+
@missing_changelog_message = <<MISSING_CHANGELOG
|
19
|
+
Hello, I'm #{@bot}, I'm here to help you accomplish your pull request submission quest
|
20
|
+
|
21
|
+
You still need to accomplish these tasks:
|
22
|
+
|
23
|
+
* Please add a changelog information
|
24
|
+
|
25
|
+
Also note that your pull request name will appears in the details section
|
26
|
+
of the release notes, so please make it clear
|
27
|
+
MISSING_CHANGELOG
|
28
|
+
|
29
|
+
@ok_changelog_message = <<OK_CHANGELOG
|
30
|
+
You successfully completed the pre-requisite quest (aka updating CHANGELOG)
|
31
|
+
|
32
|
+
Also note that your pull request name will appears in the details section
|
33
|
+
of the release notes, so please make it clear, if not already done.
|
34
|
+
|
35
|
+
#{@mention} Dear master, would you please have a look to this humble request
|
36
|
+
OK_CHANGELOG
|
37
|
+
|
38
|
+
#Connect to Github
|
39
|
+
@client=Octokit::Client.new(:login => @bot, :password => @password)
|
40
|
+
|
41
|
+
|
42
|
+
#For each open pull
|
43
|
+
Octokit.pull_requests(@repository).each do |pull|
|
44
|
+
#Get botComment
|
45
|
+
botComment = nil
|
46
|
+
@client.issue_comments(@repository, pull.number, {
|
47
|
+
:sort => "created",
|
48
|
+
:direction => "desc"
|
49
|
+
}).each do |comment|
|
50
|
+
if comment.user.login == @bot
|
51
|
+
botComment = comment
|
52
|
+
break
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if !botComment.nil? and botComment.body.start_with?("[BOT-OK]")
|
57
|
+
#Pull already validated by bot, nothing to do
|
58
|
+
puts "Pull request #{pull.number}, already ok for bot"
|
59
|
+
else
|
60
|
+
#Firt encounter, or previous [BOT-WARN] status
|
61
|
+
#Check for changelog
|
62
|
+
warnOnMissingChangeLog = true
|
63
|
+
@client.pull_request_files(@repository, pull.number).each do |changedFile|
|
64
|
+
if changedFile.filename == "CHANGELOG"
|
65
|
+
if changedFile.additions.to_i > 0
|
66
|
+
#Changelog looks good
|
67
|
+
warnOnMissingChangeLog = false
|
68
|
+
else
|
69
|
+
#No additions, means crazy deletion
|
70
|
+
warnOnMissingChangeLog = true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
if warnOnMissingChangeLog
|
75
|
+
if botComment.nil?
|
76
|
+
puts "Pull request #{pull.number}, adding bot warning"
|
77
|
+
@client.add_comment(@repository, pull.number, "[BOT-WARN] #{@missing_changelog_message}")
|
78
|
+
else
|
79
|
+
puts "Pull request #{pull.number}, already warned, no changes yet"
|
80
|
+
end
|
81
|
+
else
|
82
|
+
if !botComment.nil?
|
83
|
+
@client.delete_comment(@repository,botComment.id)
|
84
|
+
end
|
85
|
+
puts "Pull request #{pull.number}, adding bot ok"
|
86
|
+
@client.add_comment(@repository, pull.number, "[BOT-OK] #{@ok_changelog_message}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
---
|
2
|
+
title: Configuration Language - logstash
|
3
|
+
layout: content_right
|
4
|
+
---
|
5
|
+
# LogStash Config Language
|
6
|
+
|
7
|
+
The logstash config language aims to be simple.
|
8
|
+
|
9
|
+
There's 3 main sections: inputs, filters, outputs. Each section has
|
10
|
+
configurations for each plugin available in that section.
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
# This is a comment. You should use comments to describe
|
15
|
+
# parts of your configuration.
|
16
|
+
input {
|
17
|
+
...
|
18
|
+
}
|
19
|
+
|
20
|
+
filter {
|
21
|
+
...
|
22
|
+
}
|
23
|
+
|
24
|
+
output {
|
25
|
+
...
|
26
|
+
}
|
27
|
+
|
28
|
+
## Filters and Ordering
|
29
|
+
|
30
|
+
For a given event, are applied in the order of appearance in the
|
31
|
+
configuration file.
|
32
|
+
|
33
|
+
## Comments
|
34
|
+
|
35
|
+
Comments are as in ruby, perl, and python. Starts with a '#' character. Example:
|
36
|
+
|
37
|
+
# this is a comment
|
38
|
+
|
39
|
+
input { # comments can appear at the end of a line, too
|
40
|
+
# ...
|
41
|
+
}
|
42
|
+
|
43
|
+
## Plugins
|
44
|
+
|
45
|
+
The input, filter, and output sections all let you configure plugins. Plugins
|
46
|
+
configuration consists of the plugin name followed by a block of settings for
|
47
|
+
that plugin. For example, how about two file inputs:
|
48
|
+
|
49
|
+
input {
|
50
|
+
file {
|
51
|
+
path => "/var/log/messages"
|
52
|
+
type => "syslog"
|
53
|
+
}
|
54
|
+
|
55
|
+
file {
|
56
|
+
path => "/var/log/apache/access.log"
|
57
|
+
type => "apache"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
The above configures a two file separate inputs. Both set two
|
62
|
+
configuration settings each: path and type. Each plugin has different
|
63
|
+
settings for configuring it, seek the documentation for your plugin to
|
64
|
+
learn what settings are available and what they mean. For example, the
|
65
|
+
[file input][fileinput] documentation will explain the meanings of the
|
66
|
+
path and type settings.
|
67
|
+
|
68
|
+
[fileinput]: inputs/file
|
69
|
+
|
70
|
+
## Value Types
|
71
|
+
|
72
|
+
The documentation for a plugin may say that a configuration field has a
|
73
|
+
certain type. Examples include boolean, string, array, number, hash,
|
74
|
+
etc.
|
75
|
+
|
76
|
+
### <a name="boolean"></a>Boolean
|
77
|
+
|
78
|
+
A boolean must be either `true` or `false`.
|
79
|
+
|
80
|
+
Examples:
|
81
|
+
|
82
|
+
debug => true
|
83
|
+
|
84
|
+
### <a name="string"></a>String
|
85
|
+
|
86
|
+
A string must be a single value.
|
87
|
+
|
88
|
+
Example:
|
89
|
+
|
90
|
+
name => "Hello world"
|
91
|
+
|
92
|
+
Single, unquoted words are valid as strings, too, but you should use quotes.
|
93
|
+
|
94
|
+
### <a name="number"></a>Number
|
95
|
+
|
96
|
+
Numbers must be valid numerics (floating point or integer are OK)
|
97
|
+
|
98
|
+
Example:
|
99
|
+
|
100
|
+
port => 33
|
101
|
+
|
102
|
+
### <a name="array"></a>Array
|
103
|
+
|
104
|
+
An array can be a single string value or multiple. If you specify the same
|
105
|
+
field multiple times, it appends to the array.
|
106
|
+
|
107
|
+
Examples:
|
108
|
+
|
109
|
+
path => [ "/var/log/messages", "/var/log/*.log" ]
|
110
|
+
path => "/data/mysql/mysql.log"
|
111
|
+
|
112
|
+
The above makes 'path' a 3-element array including all 3 strings.
|
113
|
+
|
114
|
+
### <a name="hash"></a>Hash
|
115
|
+
|
116
|
+
A hash is basically the same syntax as Ruby hashes.
|
117
|
+
The key and value are simply pairs, such as:
|
118
|
+
|
119
|
+
match => { "field1" => "value1", "field2" => "value2", ... }
|
120
|
+
|
121
|
+
## <a name="fieldreferences"></a>Field References
|
122
|
+
|
123
|
+
All events have properties. For example, an apache access log would have things
|
124
|
+
like status code, request path, http verb, client ip, etc. Logstash calls these
|
125
|
+
properties "fields."
|
126
|
+
|
127
|
+
In many cases, it is useful to be able to refer to a field by name. To do this,
|
128
|
+
you can use the logstash field reference syntax.
|
129
|
+
|
130
|
+
By way of example, let us suppose we have this event:
|
131
|
+
|
132
|
+
{
|
133
|
+
"agent": "Mozilla/5.0 (compatible; MSIE 9.0)",
|
134
|
+
"ip": "192.168.24.44",
|
135
|
+
"request": "/index.html"
|
136
|
+
"response": {
|
137
|
+
"status": 200,
|
138
|
+
"bytes": 52353
|
139
|
+
},
|
140
|
+
"ua": {
|
141
|
+
"os": "Windows 7"
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
- the syntax to access fields is `[fieldname]`.
|
146
|
+
- if you are only referring to a **top-level field**, you can omit the `[]` and
|
147
|
+
simply say `fieldname`.
|
148
|
+
- in the case of **nested fields**, like the "os" field above, you need
|
149
|
+
the full path to that field: `[ua][os]`.
|
150
|
+
|
151
|
+
## <a name="sprintf"></a>sprintf format
|
152
|
+
|
153
|
+
This syntax is also used in what logstash calls 'sprintf format'. This format
|
154
|
+
allows you to refer to field values from within other strings. For example, the
|
155
|
+
statsd output has an 'increment' setting, to allow you to keep a count of
|
156
|
+
apache logs by status code:
|
157
|
+
|
158
|
+
output {
|
159
|
+
statsd {
|
160
|
+
increment => "apache.%{[response][status]}"
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
You can also do time formatting in this sprintf format. Instead of specifying a field name, use the `+FORMAT` syntax where `FORMAT` is a [time format](http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html).
|
165
|
+
|
166
|
+
For example, if you want to use the file output to write to logs based on the
|
167
|
+
hour and the 'type' field:
|
168
|
+
|
169
|
+
output {
|
170
|
+
file {
|
171
|
+
path => "/var/log/%{type}.%{+yyyy.MM.dd.HH}"
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
## <a name="conditionals"></a>Conditionals
|
176
|
+
|
177
|
+
Sometimes you only want a filter or output to process an event under
|
178
|
+
certain conditions. For that, you'll want to use a conditional!
|
179
|
+
|
180
|
+
Conditionals in logstash look and act the same way they do in programming
|
181
|
+
languages. You have `if`, `else if` and `else` statements. Conditionals may be
|
182
|
+
nested if you need that.
|
183
|
+
|
184
|
+
The syntax is follows:
|
185
|
+
|
186
|
+
if EXPRESSION {
|
187
|
+
...
|
188
|
+
} else if EXPRESSION {
|
189
|
+
...
|
190
|
+
} else {
|
191
|
+
...
|
192
|
+
}
|
193
|
+
|
194
|
+
What's an expression? Comparison tests, boolean logic, etc!
|
195
|
+
|
196
|
+
The following comparison operators are supported:
|
197
|
+
|
198
|
+
* equality, etc: == != < > <= >=
|
199
|
+
* regexp: =~ !~
|
200
|
+
* inclusion: in, not in
|
201
|
+
|
202
|
+
The following boolean operators are supported:
|
203
|
+
|
204
|
+
* and, or, nand, xor
|
205
|
+
|
206
|
+
The following unary operators are supported:
|
207
|
+
|
208
|
+
* !
|
209
|
+
|
210
|
+
Expressions may contain expressions. Expressions may be negated with `!`.
|
211
|
+
Expressions may be grouped with parentheses `(...)`. Expressions can be long
|
212
|
+
and complex.
|
213
|
+
|
214
|
+
For example, if we want to remove the field `secret` if the field
|
215
|
+
`action` has a value of `login`:
|
216
|
+
|
217
|
+
filter {
|
218
|
+
if [action] == "login" {
|
219
|
+
mutate { remove => "secret" }
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
The above uses the field reference syntax to get the value of the
|
224
|
+
`action` field. It is compared against the text `login` and, when equal,
|
225
|
+
allows the mutate filter to do delete the field named `secret`
|
226
|
+
|
227
|
+
How about a more complex example?
|
228
|
+
|
229
|
+
* alert nagios of any apache events with status 5xx
|
230
|
+
* record any 4xx status to elasticsearch
|
231
|
+
* record all status code hits via statsd
|
232
|
+
|
233
|
+
How about telling nagios of any http event that has a status code of 5xx?
|
234
|
+
|
235
|
+
output {
|
236
|
+
if [type] == "apache" {
|
237
|
+
if [status] =~ /^5\d\d/ {
|
238
|
+
nagios { ... }
|
239
|
+
} else if [status] =~ /^4\d\d/ {
|
240
|
+
elasticsearch { ... }
|
241
|
+
}
|
242
|
+
|
243
|
+
statsd { increment => "apache.%{status}" }
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
You can also do multiple expressions in a single condition:
|
248
|
+
|
249
|
+
output {
|
250
|
+
# Send production errors to pagerduty
|
251
|
+
if [loglevel] == "ERROR" and [deployment] == "production" {
|
252
|
+
pagerduty {
|
253
|
+
...
|
254
|
+
}
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
## Further Reading
|
259
|
+
|
260
|
+
For more information, see [the plugin docs index](index)
|