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,43 @@
|
|
1
|
+
require "test_utils"
|
2
|
+
require "logstash/filters/environment"
|
3
|
+
|
4
|
+
describe LogStash::Filters::Environment do
|
5
|
+
extend LogStash::RSpec
|
6
|
+
|
7
|
+
describe "add a field from the environment" do
|
8
|
+
# The logstash config goes here.
|
9
|
+
# At this time, only filters are supported.
|
10
|
+
config <<-CONFIG
|
11
|
+
filter {
|
12
|
+
environment {
|
13
|
+
add_field_from_env => [ "newfield", "MY_ENV_VAR" ]
|
14
|
+
}
|
15
|
+
}
|
16
|
+
CONFIG
|
17
|
+
|
18
|
+
ENV["MY_ENV_VAR"] = "hello world"
|
19
|
+
|
20
|
+
sample "example" do
|
21
|
+
insist { subject["newfield"] } == "hello world"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "does nothing on non-matching events" do
|
26
|
+
# The logstash config goes here.
|
27
|
+
# At this time, only filters are supported.
|
28
|
+
config <<-CONFIG
|
29
|
+
filter {
|
30
|
+
environment {
|
31
|
+
type => "foo"
|
32
|
+
add_field_from_env => [ "newfield", "MY_ENV_VAR" ]
|
33
|
+
}
|
34
|
+
}
|
35
|
+
CONFIG
|
36
|
+
|
37
|
+
ENV["MY_ENV_VAR"] = "hello world"
|
38
|
+
|
39
|
+
sample("type" => "bar", "message" => "fizz") do
|
40
|
+
insist { subject["newfield"] }.nil?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "test_utils"
|
2
|
+
require "logstash/filters/geoip"
|
3
|
+
|
4
|
+
describe LogStash::Filters::GeoIP do
|
5
|
+
extend LogStash::RSpec
|
6
|
+
describe "defaults" do
|
7
|
+
config <<-CONFIG
|
8
|
+
filter {
|
9
|
+
geoip {
|
10
|
+
source => "ip"
|
11
|
+
#database => "vendor/geoip/GeoLiteCity.dat"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
CONFIG
|
15
|
+
|
16
|
+
sample("ip" => "8.8.8.8") do
|
17
|
+
insist { subject }.include?("geoip")
|
18
|
+
|
19
|
+
expected_fields = %w(ip country_code2 country_code3 country_name
|
20
|
+
continent_code region_name city_name postal_code
|
21
|
+
latitude longitude dma_code area_code timezone
|
22
|
+
location )
|
23
|
+
expected_fields.each do |f|
|
24
|
+
insist { subject["geoip"] }.include?(f)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
sample("ip" => "127.0.0.1") do
|
29
|
+
# assume geoip fails on localhost lookups
|
30
|
+
reject { subject }.include?("geoip")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "Specify the target" do
|
35
|
+
config <<-CONFIG
|
36
|
+
filter {
|
37
|
+
geoip {
|
38
|
+
source => "ip"
|
39
|
+
#database => "vendor/geoip/GeoLiteCity.dat"
|
40
|
+
target => src_ip
|
41
|
+
}
|
42
|
+
}
|
43
|
+
CONFIG
|
44
|
+
|
45
|
+
sample("ip" => "8.8.8.8") do
|
46
|
+
insist { subject }.include?("src_ip")
|
47
|
+
|
48
|
+
expected_fields = %w(ip country_code2 country_code3 country_name
|
49
|
+
continent_code region_name city_name postal_code
|
50
|
+
latitude longitude dma_code area_code timezone
|
51
|
+
location )
|
52
|
+
expected_fields.each do |f|
|
53
|
+
insist { subject["src_ip"] }.include?(f)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
sample("ip" => "127.0.0.1") do
|
58
|
+
# assume geoip fails on localhost lookups
|
59
|
+
reject { subject }.include?("src_ip")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,342 @@
|
|
1
|
+
require "test_utils"
|
2
|
+
require "logstash/filters/grep"
|
3
|
+
|
4
|
+
describe LogStash::Filters::Grep do
|
5
|
+
extend LogStash::RSpec
|
6
|
+
|
7
|
+
describe "single grep match" do
|
8
|
+
config <<-CONFIG
|
9
|
+
filter {
|
10
|
+
grep {
|
11
|
+
match => [ "str", "test" ]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
CONFIG
|
15
|
+
|
16
|
+
sample("str" => "test: this should not be dropped") do
|
17
|
+
reject { subject }.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
sample("str" => "foo: this should be dropped") do
|
21
|
+
insist { subject }.nil?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "single match failure cancels the event" do
|
26
|
+
config <<-CONFIG
|
27
|
+
filter {
|
28
|
+
grep {
|
29
|
+
match => [ "str", "test" ]
|
30
|
+
}
|
31
|
+
}
|
32
|
+
CONFIG
|
33
|
+
|
34
|
+
sample("str" => "foo: this should be dropped") do
|
35
|
+
insist { subject }.nil?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "single match failure does not cancel the event with drop set to false" do
|
40
|
+
config <<-CONFIG
|
41
|
+
filter {
|
42
|
+
grep {
|
43
|
+
match => [ "str", "test" ]
|
44
|
+
drop => false
|
45
|
+
}
|
46
|
+
}
|
47
|
+
CONFIG
|
48
|
+
|
49
|
+
sample("str" => "foo: this should not be dropped") do
|
50
|
+
reject { subject }.nil?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "multiple match conditions" do
|
55
|
+
config <<-CONFIG
|
56
|
+
filter {
|
57
|
+
grep {
|
58
|
+
match => [
|
59
|
+
"str", "test",
|
60
|
+
"bar", "baz"
|
61
|
+
]
|
62
|
+
}
|
63
|
+
}
|
64
|
+
CONFIG
|
65
|
+
|
66
|
+
sample("str" => "test: this should not be dropped", "bar" => "foo baz foo") do
|
67
|
+
reject { subject }.nil?
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "multiple match conditions should cancel on failure" do
|
72
|
+
config <<-CONFIG
|
73
|
+
filter {
|
74
|
+
grep {
|
75
|
+
match => [
|
76
|
+
"str", "test",
|
77
|
+
"bar", "baz"
|
78
|
+
]
|
79
|
+
}
|
80
|
+
}
|
81
|
+
CONFIG
|
82
|
+
|
83
|
+
sample("str" => "test: this should be dropped", "bar" => "foo bAz foo") do
|
84
|
+
insist { subject }.nil?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "single condition with regexp syntax" do
|
89
|
+
config <<-CONFIG
|
90
|
+
filter {
|
91
|
+
grep {
|
92
|
+
match => [ "str", "(?i)test.*foo"]
|
93
|
+
}
|
94
|
+
}
|
95
|
+
CONFIG
|
96
|
+
|
97
|
+
sample("str" => "TeST regexp match FoO") do
|
98
|
+
reject { subject }.nil?
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "single condition with regexp syntax cancels on failure" do
|
103
|
+
config <<-CONFIG
|
104
|
+
filter {
|
105
|
+
grep {
|
106
|
+
match => [ "str", "test.*foo" ]
|
107
|
+
}
|
108
|
+
}
|
109
|
+
CONFIG
|
110
|
+
|
111
|
+
sample("str" => "TeST regexp match FoO") do
|
112
|
+
insist { subject }.nil?
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "adding one field on success" do
|
117
|
+
config <<-CONFIG
|
118
|
+
filter {
|
119
|
+
grep {
|
120
|
+
match => [ "str", "test" ]
|
121
|
+
add_field => ["new_field", "new_value"]
|
122
|
+
}
|
123
|
+
}
|
124
|
+
CONFIG
|
125
|
+
|
126
|
+
sample("str" => "test") do
|
127
|
+
reject { subject }.nil?
|
128
|
+
insist { subject["new_field"]} == "new_value"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "adding one field with a sprintf value" do
|
133
|
+
config <<-CONFIG
|
134
|
+
filter {
|
135
|
+
grep {
|
136
|
+
match => [ "str", "test" ]
|
137
|
+
add_field => ["new_field", "%{type}"]
|
138
|
+
}
|
139
|
+
}
|
140
|
+
CONFIG
|
141
|
+
|
142
|
+
sample("type" => "grepper", "str" => "test") do
|
143
|
+
reject { subject }.nil?
|
144
|
+
insist { subject["new_field"]} == subject["type"]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# following test was __DISABLED_FOR_NOW_, remember why ?
|
149
|
+
# Seems to be multi-match several time on the same field not allowed
|
150
|
+
# maybe a clearer test on multi-match on same field could be created
|
151
|
+
# Also add_field behaviour tested separately in new NOOP test for add_field
|
152
|
+
|
153
|
+
# describe "adding fields on successful multiple match" do
|
154
|
+
# config <<-CONFIG
|
155
|
+
# filter {
|
156
|
+
# grep {
|
157
|
+
# match => [ "str", "test" ]
|
158
|
+
# add_field => ["new_field", "new_value"]
|
159
|
+
# match => [ "str", ".*" ]
|
160
|
+
# add_field => ["new_field", "new_value_2"]
|
161
|
+
# }
|
162
|
+
# }
|
163
|
+
# CONFIG
|
164
|
+
#
|
165
|
+
# sample("type" => "grepper", "str" => "test") do
|
166
|
+
# reject { subject }.nil?
|
167
|
+
# insist { subject["new_field"]} == ["new_value", "new_value_2"]
|
168
|
+
# end
|
169
|
+
# end
|
170
|
+
|
171
|
+
describe "add tags" do
|
172
|
+
config <<-CONFIG
|
173
|
+
filter {
|
174
|
+
grep {
|
175
|
+
match => [ "str", "test" ]
|
176
|
+
add_tag => ["new_tag"]
|
177
|
+
}
|
178
|
+
}
|
179
|
+
CONFIG
|
180
|
+
|
181
|
+
sample("tags" => ["tag"], "str" => "test") do
|
182
|
+
reject { subject }.nil?
|
183
|
+
insist { subject["tags"]} == ["tag", "new_tag"]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "add tags with drop set to false tags matching events" do
|
188
|
+
config <<-CONFIG
|
189
|
+
filter {
|
190
|
+
grep {
|
191
|
+
match => [ "str", "test" ]
|
192
|
+
drop => false
|
193
|
+
add_tag => ["new_tag"]
|
194
|
+
}
|
195
|
+
}
|
196
|
+
CONFIG
|
197
|
+
|
198
|
+
sample("tags" => ["tag"], "str" => "test") do
|
199
|
+
reject { subject }.nil?
|
200
|
+
insist { subject["tags"]} == ["tag", "new_tag"]
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "add tags with drop set to false allows non-matching events through" do
|
205
|
+
config <<-CONFIG
|
206
|
+
filter {
|
207
|
+
grep {
|
208
|
+
match => [ "str", "test" ]
|
209
|
+
drop => false
|
210
|
+
add_tag => ["new_tag"]
|
211
|
+
}
|
212
|
+
}
|
213
|
+
CONFIG
|
214
|
+
|
215
|
+
sample("tags" => ["tag"], "str" => "non-matching") do
|
216
|
+
reject { subject }.nil?
|
217
|
+
insist { subject["tags"]} == ["tag"]
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "add tags with sprintf value" do
|
222
|
+
config <<-CONFIG
|
223
|
+
filter {
|
224
|
+
grep {
|
225
|
+
match => [ "str", "test" ]
|
226
|
+
add_tag => ["%{str}"]
|
227
|
+
}
|
228
|
+
}
|
229
|
+
CONFIG
|
230
|
+
|
231
|
+
sample("tags" => ["tag"], "str" => "test") do
|
232
|
+
reject { subject }.nil?
|
233
|
+
insist { subject["tags"]} == ["tag", subject["str"]]
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "negate=true should not cause drops when field is nil" do
|
238
|
+
# Set negate to true; the pattern being searched doesn't actually matter
|
239
|
+
# here. We're testing to make sure "grep -v" behavior doesn't drop events
|
240
|
+
# that don't even have the field being filtered for.
|
241
|
+
config <<-CONFIG
|
242
|
+
filter {
|
243
|
+
grep {
|
244
|
+
match => [ "str", "doesn't matter lol" ]
|
245
|
+
negate => true
|
246
|
+
}
|
247
|
+
}
|
248
|
+
CONFIG
|
249
|
+
|
250
|
+
sample("tags" => ["tag"], "str" => nil) do
|
251
|
+
reject { subject }.nil?
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
#LOGSTASH-599
|
256
|
+
describe "drop line based on type and tags 'matching' only but otherwise pattern matching" do
|
257
|
+
config <<-CONFIG
|
258
|
+
filter {
|
259
|
+
grep {
|
260
|
+
type => "testing"
|
261
|
+
tags => ["_grokparsefailure"]
|
262
|
+
negate => true
|
263
|
+
}
|
264
|
+
}
|
265
|
+
CONFIG
|
266
|
+
|
267
|
+
sample("type" => "testing", "tags" => ["_grokparsefailure"], "str" => "test") do
|
268
|
+
insist { subject }.nil?
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
#LOGSTASH-894 and LOGSTASH-919
|
273
|
+
describe "repeat a field in match config, similar to piped grep command line" do
|
274
|
+
config <<-CONFIG
|
275
|
+
filter {
|
276
|
+
grep {
|
277
|
+
match => ["message", "hello", "message", "world"]
|
278
|
+
}
|
279
|
+
}
|
280
|
+
CONFIG
|
281
|
+
|
282
|
+
#both match
|
283
|
+
sample "hello world" do
|
284
|
+
reject { subject }.nil?
|
285
|
+
end
|
286
|
+
#one match
|
287
|
+
sample "bye world" do
|
288
|
+
insist { subject }.nil?
|
289
|
+
end
|
290
|
+
#one match
|
291
|
+
sample "hello Jordan" do
|
292
|
+
insist { subject }.nil?
|
293
|
+
end
|
294
|
+
#no match
|
295
|
+
sample "WTF" do
|
296
|
+
insist { subject }.nil?
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
describe "repeat a field in match config, similar to several -e in grep command line" do
|
301
|
+
config <<-CONFIG
|
302
|
+
filter {
|
303
|
+
grep {
|
304
|
+
match => ["message", "hello", "message", "world"]
|
305
|
+
negate => true
|
306
|
+
}
|
307
|
+
}
|
308
|
+
CONFIG
|
309
|
+
|
310
|
+
#both match
|
311
|
+
sample "hello world" do
|
312
|
+
insist { subject }.nil?
|
313
|
+
end
|
314
|
+
#one match
|
315
|
+
sample "bye world" do
|
316
|
+
insist { subject }.nil?
|
317
|
+
end
|
318
|
+
#one match
|
319
|
+
sample "hello Jordan" do
|
320
|
+
insist { subject }.nil?
|
321
|
+
end
|
322
|
+
#no match
|
323
|
+
sample "WTF" do
|
324
|
+
reject { subject }.nil?
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
describe "case-insensitive matching" do
|
329
|
+
config <<-CONFIG
|
330
|
+
filter {
|
331
|
+
grep {
|
332
|
+
ignore_case => true
|
333
|
+
match => [ "str", "test" ]
|
334
|
+
}
|
335
|
+
}
|
336
|
+
CONFIG
|
337
|
+
|
338
|
+
sample("str" => "tEsT: this should still be matched") do
|
339
|
+
reject { subject }.nil?
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
@@ -0,0 +1,473 @@
|
|
1
|
+
require "test_utils"
|
2
|
+
require "logstash/filters/grok"
|
3
|
+
|
4
|
+
describe LogStash::Filters::Grok do
|
5
|
+
extend LogStash::RSpec
|
6
|
+
|
7
|
+
describe "simple syslog line" do
|
8
|
+
# The logstash config goes here.
|
9
|
+
# At this time, only filters are supported.
|
10
|
+
config <<-CONFIG
|
11
|
+
filter {
|
12
|
+
grok {
|
13
|
+
match => [ "message", "%{SYSLOGLINE}" ]
|
14
|
+
singles => true
|
15
|
+
overwrite => [ "message" ]
|
16
|
+
}
|
17
|
+
}
|
18
|
+
CONFIG
|
19
|
+
|
20
|
+
sample "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from camomile.cloud9.net[168.100.1.3]" do
|
21
|
+
insist { subject["tags"] }.nil?
|
22
|
+
insist { subject["logsource"] } == "evita"
|
23
|
+
insist { subject["timestamp"] } == "Mar 16 00:01:25"
|
24
|
+
insist { subject["message"] } == "connect from camomile.cloud9.net[168.100.1.3]"
|
25
|
+
insist { subject["program"] } == "postfix/smtpd"
|
26
|
+
insist { subject["pid"] } == "1713"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "ietf 5424 syslog line" do
|
31
|
+
# The logstash config goes here.
|
32
|
+
# At this time, only filters are supported.
|
33
|
+
config <<-CONFIG
|
34
|
+
filter {
|
35
|
+
grok {
|
36
|
+
match => [ "message", "%{SYSLOG5424LINE}" ]
|
37
|
+
singles => true
|
38
|
+
}
|
39
|
+
}
|
40
|
+
CONFIG
|
41
|
+
|
42
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - [id1 foo=\"bar\"][id2 baz=\"something\"] Hello, syslog." do
|
43
|
+
insist { subject["tags"] }.nil?
|
44
|
+
insist { subject["syslog5424_pri"] } == "191"
|
45
|
+
insist { subject["syslog5424_ver"] } == "1"
|
46
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
47
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
48
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
49
|
+
insist { subject["syslog5424_proc"] } == "4123"
|
50
|
+
insist { subject["syslog5424_msgid"] } == nil
|
51
|
+
insist { subject["syslog5424_sd"] } == "[id1 foo=\"bar\"][id2 baz=\"something\"]"
|
52
|
+
insist { subject["syslog5424_msg"] } == "Hello, syslog."
|
53
|
+
end
|
54
|
+
|
55
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug - - [id1 foo=\"bar\"] No process ID." do
|
56
|
+
insist { subject["tags"] }.nil?
|
57
|
+
insist { subject["syslog5424_pri"] } == "191"
|
58
|
+
insist { subject["syslog5424_ver"] } == "1"
|
59
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
60
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
61
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
62
|
+
insist { subject["syslog5424_proc"] } == nil
|
63
|
+
insist { subject["syslog5424_msgid"] } == nil
|
64
|
+
insist { subject["syslog5424_sd"] } == "[id1 foo=\"bar\"]"
|
65
|
+
insist { subject["syslog5424_msg"] } == "No process ID."
|
66
|
+
end
|
67
|
+
|
68
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - - No structured data." do
|
69
|
+
insist { subject["tags"] }.nil?
|
70
|
+
insist { subject["syslog5424_pri"] } == "191"
|
71
|
+
insist { subject["syslog5424_ver"] } == "1"
|
72
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
73
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
74
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
75
|
+
insist { subject["syslog5424_proc"] } == "4123"
|
76
|
+
insist { subject["syslog5424_msgid"] } == nil
|
77
|
+
insist { subject["syslog5424_sd"] } == nil
|
78
|
+
insist { subject["syslog5424_msg"] } == "No structured data."
|
79
|
+
end
|
80
|
+
|
81
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug - - - No PID or SD." do
|
82
|
+
insist { subject["tags"] }.nil?
|
83
|
+
insist { subject["syslog5424_pri"] } == "191"
|
84
|
+
insist { subject["syslog5424_ver"] } == "1"
|
85
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
86
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
87
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
88
|
+
insist { subject["syslog5424_proc"] } == nil
|
89
|
+
insist { subject["syslog5424_msgid"] } == nil
|
90
|
+
insist { subject["syslog5424_sd"] } == nil
|
91
|
+
insist { subject["syslog5424_msg"] } == "No PID or SD."
|
92
|
+
end
|
93
|
+
|
94
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - Missing structured data." do
|
95
|
+
insist { subject["tags"] }.nil?
|
96
|
+
insist { subject["syslog5424_pri"] } == "191"
|
97
|
+
insist { subject["syslog5424_ver"] } == "1"
|
98
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
99
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
100
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
101
|
+
insist { subject["syslog5424_proc"] } == "4123"
|
102
|
+
insist { subject["syslog5424_msgid"] } == nil
|
103
|
+
insist { subject["syslog5424_sd"] } == nil
|
104
|
+
insist { subject["syslog5424_msg"] } == "Missing structured data."
|
105
|
+
end
|
106
|
+
|
107
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - - Additional spaces." do
|
108
|
+
insist { subject["tags"] }.nil?
|
109
|
+
insist { subject["syslog5424_pri"] } == "191"
|
110
|
+
insist { subject["syslog5424_ver"] } == "1"
|
111
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
112
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
113
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
114
|
+
insist { subject["syslog5424_proc"] } == "4123"
|
115
|
+
insist { subject["syslog5424_msgid"] } == nil
|
116
|
+
insist { subject["syslog5424_sd"] } == nil
|
117
|
+
insist { subject["syslog5424_msg"] } == "Additional spaces."
|
118
|
+
end
|
119
|
+
|
120
|
+
sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - Additional spaces and missing SD." do
|
121
|
+
insist { subject["tags"] }.nil?
|
122
|
+
insist { subject["syslog5424_pri"] } == "191"
|
123
|
+
insist { subject["syslog5424_ver"] } == "1"
|
124
|
+
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
|
125
|
+
insist { subject["syslog5424_host"] } == "paxton.local"
|
126
|
+
insist { subject["syslog5424_app"] } == "grokdebug"
|
127
|
+
insist { subject["syslog5424_proc"] } == "4123"
|
128
|
+
insist { subject["syslog5424_msgid"] } == nil
|
129
|
+
insist { subject["syslog5424_sd"] } == nil
|
130
|
+
insist { subject["syslog5424_msg"] } == "Additional spaces and missing SD."
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "parsing an event with multiple messages (array of strings)", :if => false do
|
135
|
+
config <<-CONFIG
|
136
|
+
filter {
|
137
|
+
grok {
|
138
|
+
match => [ "message", "(?:hello|world) %{NUMBER}" ]
|
139
|
+
named_captures_only => false
|
140
|
+
}
|
141
|
+
}
|
142
|
+
CONFIG
|
143
|
+
|
144
|
+
sample("message" => [ "hello 12345", "world 23456" ]) do
|
145
|
+
insist { subject["NUMBER"] } == [ "12345", "23456" ]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "coercing matched values" do
|
150
|
+
config <<-CONFIG
|
151
|
+
filter {
|
152
|
+
grok {
|
153
|
+
match => [ "message", "%{NUMBER:foo:int} %{NUMBER:bar:float}" ]
|
154
|
+
singles => true
|
155
|
+
}
|
156
|
+
}
|
157
|
+
CONFIG
|
158
|
+
|
159
|
+
sample "400 454.33" do
|
160
|
+
insist { subject["foo"] } == 400
|
161
|
+
insist { subject["foo"] }.is_a?(Fixnum)
|
162
|
+
insist { subject["bar"] } == 454.33
|
163
|
+
insist { subject["bar"] }.is_a?(Float)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "in-line pattern definitions" do
|
168
|
+
config <<-CONFIG
|
169
|
+
filter {
|
170
|
+
grok {
|
171
|
+
match => [ "message", "%{FIZZLE=\\d+}" ]
|
172
|
+
named_captures_only => false
|
173
|
+
singles => true
|
174
|
+
}
|
175
|
+
}
|
176
|
+
CONFIG
|
177
|
+
|
178
|
+
sample "hello 1234" do
|
179
|
+
insist { subject["FIZZLE"] } == "1234"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "processing selected fields" do
|
184
|
+
config <<-CONFIG
|
185
|
+
filter {
|
186
|
+
grok {
|
187
|
+
match => [ "message", "%{WORD:word}" ]
|
188
|
+
match => [ "examplefield", "%{NUMBER:num}" ]
|
189
|
+
break_on_match => false
|
190
|
+
singles => true
|
191
|
+
}
|
192
|
+
}
|
193
|
+
CONFIG
|
194
|
+
|
195
|
+
sample("message" => "hello world", "examplefield" => "12345") do
|
196
|
+
insist { subject["examplefield"] } == "12345"
|
197
|
+
insist { subject["word"] } == "hello"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "adding fields on match" do
|
202
|
+
config <<-CONFIG
|
203
|
+
filter {
|
204
|
+
grok {
|
205
|
+
match => [ "message", "matchme %{NUMBER:fancy}" ]
|
206
|
+
singles => true
|
207
|
+
add_field => [ "new_field", "%{fancy}" ]
|
208
|
+
}
|
209
|
+
}
|
210
|
+
CONFIG
|
211
|
+
|
212
|
+
sample "matchme 1234" do
|
213
|
+
insist { subject["tags"] }.nil?
|
214
|
+
insist { subject["new_field"] } == "1234"
|
215
|
+
end
|
216
|
+
|
217
|
+
sample "this will not be matched" do
|
218
|
+
insist { subject["tags"] }.include?("_grokparsefailure")
|
219
|
+
reject { subject }.include?("new_field")
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "empty fields" do
|
224
|
+
describe "drop by default" do
|
225
|
+
config <<-CONFIG
|
226
|
+
filter {
|
227
|
+
grok {
|
228
|
+
match => [ "message", "1=%{WORD:foo1} *(2=%{WORD:foo2})?" ]
|
229
|
+
}
|
230
|
+
}
|
231
|
+
CONFIG
|
232
|
+
|
233
|
+
sample "1=test" do
|
234
|
+
insist { subject["tags"] }.nil?
|
235
|
+
insist { subject }.include?("foo1")
|
236
|
+
|
237
|
+
# Since 'foo2' was not captured, it must not be present in the event.
|
238
|
+
reject { subject }.include?("foo2")
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "keep if keep_empty_captures is true" do
|
243
|
+
config <<-CONFIG
|
244
|
+
filter {
|
245
|
+
grok {
|
246
|
+
match => [ "message", "1=%{WORD:foo1} *(2=%{WORD:foo2})?" ]
|
247
|
+
keep_empty_captures => true
|
248
|
+
}
|
249
|
+
}
|
250
|
+
CONFIG
|
251
|
+
|
252
|
+
sample "1=test" do
|
253
|
+
insist { subject["tags"] }.nil?
|
254
|
+
# use .to_hash for this test, for now, because right now
|
255
|
+
# the Event.include? returns false for missing fields as well
|
256
|
+
# as for fields with nil values.
|
257
|
+
insist { subject.to_hash }.include?("foo2")
|
258
|
+
insist { subject.to_hash }.include?("foo2")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "when named_captures_only == false" do
|
264
|
+
config <<-CONFIG
|
265
|
+
filter {
|
266
|
+
grok {
|
267
|
+
match => [ "message", "Hello %{WORD}. %{WORD:foo}" ]
|
268
|
+
named_captures_only => false
|
269
|
+
singles => true
|
270
|
+
}
|
271
|
+
}
|
272
|
+
CONFIG
|
273
|
+
|
274
|
+
sample "Hello World, yo!" do
|
275
|
+
insist { subject }.include?("WORD")
|
276
|
+
insist { subject["WORD"] } == "World"
|
277
|
+
insist { subject }.include?("foo")
|
278
|
+
insist { subject["foo"] } == "yo"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe "using oniguruma named captures (?<name>regex)" do
|
283
|
+
context "plain regexp" do
|
284
|
+
config <<-'CONFIG'
|
285
|
+
filter {
|
286
|
+
grok {
|
287
|
+
singles => true
|
288
|
+
match => [ "message", "(?<foo>\w+)" ]
|
289
|
+
}
|
290
|
+
}
|
291
|
+
CONFIG
|
292
|
+
sample "hello world" do
|
293
|
+
insist { subject["tags"] }.nil?
|
294
|
+
insist { subject["foo"] } == "hello"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context "grok patterns" do
|
299
|
+
config <<-'CONFIG'
|
300
|
+
filter {
|
301
|
+
grok {
|
302
|
+
singles => true
|
303
|
+
match => [ "message", "(?<timestamp>%{DATE_EU} %{TIME})" ]
|
304
|
+
}
|
305
|
+
}
|
306
|
+
CONFIG
|
307
|
+
|
308
|
+
sample "fancy 12-12-12 12:12:12" do
|
309
|
+
insist { subject["tags"] }.nil?
|
310
|
+
insist { subject["timestamp"] } == "12-12-12 12:12:12"
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
describe "grok on integer types" do
|
316
|
+
config <<-'CONFIG'
|
317
|
+
filter {
|
318
|
+
grok {
|
319
|
+
match => [ "status", "^403$" ]
|
320
|
+
add_tag => "four_oh_three"
|
321
|
+
}
|
322
|
+
}
|
323
|
+
CONFIG
|
324
|
+
|
325
|
+
sample("status" => 403) do
|
326
|
+
reject { subject["tags"] }.include?("_grokparsefailure")
|
327
|
+
insist { subject["tags"] }.include?("four_oh_three")
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe "grok on float types" do
|
332
|
+
config <<-'CONFIG'
|
333
|
+
filter {
|
334
|
+
grok {
|
335
|
+
match => [ "version", "^1.0$" ]
|
336
|
+
add_tag => "one_point_oh"
|
337
|
+
}
|
338
|
+
}
|
339
|
+
CONFIG
|
340
|
+
|
341
|
+
sample("version" => 1.0) do
|
342
|
+
insist { subject["tags"] }.include?("one_point_oh")
|
343
|
+
insist { subject["tags"] }.include?("one_point_oh")
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
describe "grok on %{LOGLEVEL}" do
|
348
|
+
config <<-'CONFIG'
|
349
|
+
filter {
|
350
|
+
grok {
|
351
|
+
pattern => "%{LOGLEVEL:level}: error!"
|
352
|
+
}
|
353
|
+
}
|
354
|
+
CONFIG
|
355
|
+
|
356
|
+
log_level_names = %w(
|
357
|
+
trace Trace TRACE
|
358
|
+
debug Debug DEBUG
|
359
|
+
notice Notice Notice
|
360
|
+
info Info INFO
|
361
|
+
warn warning Warn Warning WARN WARNING
|
362
|
+
err error Err Error ERR ERROR
|
363
|
+
crit critical Crit Critical CRIT CRITICAL
|
364
|
+
fatal Fatal FATAL
|
365
|
+
severe Severe SEVERE
|
366
|
+
emerg emergency Emerg Emergency EMERG EMERGENCY
|
367
|
+
)
|
368
|
+
log_level_names.each do |level_name|
|
369
|
+
sample "#{level_name}: error!" do
|
370
|
+
insist { subject['level'] } == level_name
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe "tagging on failure" do
|
376
|
+
config <<-CONFIG
|
377
|
+
filter {
|
378
|
+
grok {
|
379
|
+
match => [ "message", "matchme %{NUMBER:fancy}" ]
|
380
|
+
tag_on_failure => false
|
381
|
+
}
|
382
|
+
}
|
383
|
+
CONFIG
|
384
|
+
|
385
|
+
sample "matchme 1234" do
|
386
|
+
insist { subject["tags"] }.nil?
|
387
|
+
end
|
388
|
+
|
389
|
+
sample "this will not be matched" do
|
390
|
+
insist { subject["tags"] }.include?("false")
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
describe "captures named fields even if the whole text matches" do
|
395
|
+
config <<-CONFIG
|
396
|
+
filter {
|
397
|
+
grok {
|
398
|
+
match => [ "message", "%{DATE_EU:stimestamp}" ]
|
399
|
+
singles => true
|
400
|
+
}
|
401
|
+
}
|
402
|
+
CONFIG
|
403
|
+
|
404
|
+
sample "11/01/01" do
|
405
|
+
insist { subject["stimestamp"] } == "11/01/01"
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
describe "allow dashes in capture names" do
|
410
|
+
config <<-CONFIG
|
411
|
+
filter {
|
412
|
+
grok {
|
413
|
+
match => [ "message", "%{WORD:foo-bar}" ]
|
414
|
+
singles => true
|
415
|
+
}
|
416
|
+
}
|
417
|
+
CONFIG
|
418
|
+
|
419
|
+
sample "hello world" do
|
420
|
+
insist { subject["foo-bar"] } == "hello"
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
describe "performance test", :if => ENV["SPEEDTEST"] do
|
425
|
+
event_count = 100000
|
426
|
+
min_rate = 4000
|
427
|
+
|
428
|
+
max_duration = event_count / min_rate
|
429
|
+
input = "Nov 24 01:29:01 -0800"
|
430
|
+
config <<-CONFIG
|
431
|
+
input {
|
432
|
+
generator {
|
433
|
+
count => #{event_count}
|
434
|
+
message => "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from camomile.cloud9.net[168.100.1.3]"
|
435
|
+
}
|
436
|
+
}
|
437
|
+
filter {
|
438
|
+
grok {
|
439
|
+
match => [ "message", "%{SYSLOGLINE}" ]
|
440
|
+
singles => true
|
441
|
+
overwrite => [ "message" ]
|
442
|
+
}
|
443
|
+
}
|
444
|
+
output { null { } }
|
445
|
+
CONFIG
|
446
|
+
|
447
|
+
2.times do
|
448
|
+
agent do
|
449
|
+
puts "grok parse rate: #{event_count / @duration}"
|
450
|
+
insist { @duration } < max_duration
|
451
|
+
end
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
describe "singles with duplicate-named fields" do
|
456
|
+
config <<-CONFIG
|
457
|
+
filter {
|
458
|
+
grok {
|
459
|
+
match => [ "message", "%{INT:foo}|%{WORD:foo}" ]
|
460
|
+
singles => true
|
461
|
+
}
|
462
|
+
}
|
463
|
+
CONFIG
|
464
|
+
|
465
|
+
sample "hello world" do
|
466
|
+
insist { subject["foo"] }.is_a?(String)
|
467
|
+
end
|
468
|
+
|
469
|
+
sample "123 world" do
|
470
|
+
insist { subject["foo"] }.is_a?(String)
|
471
|
+
end
|
472
|
+
end
|
473
|
+
end
|