Logstash - transport and process your logs, events, or other data
Find a file
Cas Donoghue 6f89de5b35
Improve smoke tests for observability SRE image (#17486)
* Improve smoke tests for observability SRE image

This commit adds a new rspec test to run the observability SRE container in a
docker compose network with filebeat and elasticsearch. It uses some simple test
data through a pipeline with plugins we expect to be used in production. The
rspec tests will ensure the test data is flowing from filebeat to logstash to
elasticsearch by querying elasticsearch for expected transformed data.

* REVERT ME: debug whats goig on in CI :(

* Run filebeat container as root

* Work around strict file ownership perms for filebeat

We add the filebeat config in a volume, the permissions checks fail due test
runner not being a root user. This commit disables that check in filebeat as
seems to be the consensus solution online for example: https://event-driven.io/en/tricks_on_how_to_set_up_related_docker_images/

* Dynaimcally generate PKI instead of checking it in

Instead of checking in PKI, dynamically generate it with gradle task for
starting containers and running the tests. This improvement avoids github
warning of checked in keys and avoid expiration headaches. Generation is very
fast and does not add any significant overhead to test setup.

* Remove use of "should" in rspec docstrings

see https://github.com/rubocop/rspec-style-guide?tab=readme-ov-file#should-in-example-docstrings

* Ensure permissions readable for volume

Now that certs are dynamically generated, ensure they are able to be read in container

* Use elasticsearch-fips image for smoke testing

* Add git ignore for temp certs
2025-04-08 13:11:26 -07:00
.buildkite Improve smoke tests for observability SRE image (#17486) 2025-04-08 13:11:26 -07:00
.ci Enable packaging tests in exhaustive pipeline (#15781) 2024-01-12 17:52:06 +02:00
.github Update critical_vulnerability_scan.yml (#16039) 2024-03-28 15:03:07 +00:00
bin Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
buildSrc Fix IT tests after version bumps (#15827) 2024-01-23 15:13:51 +02:00
ci Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
config jackson stream read constraints: code-based defaults (#16854) (#16883) 2025-01-09 11:47:33 -08:00
data Add back missing gitkeep in data dir 2018-01-23 12:40:36 +00:00
devtools devtools/label: Add initial script that can label issues/PRs (#14296) 2022-06-28 09:13:30 -04:00
docker Configure observability SRE container for FIPS (#17297) 2025-03-13 18:40:03 -07:00
docs Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
docsk8s Logstash Getting started with Kubernetes Guide (#14655) 2022-11-16 16:06:56 -05:00
gradle/wrapper update multiple dependencies (#16136) 2024-05-08 09:13:41 +01:00
lib Backport 17203 and 17267 fedramp8x (#17271) 2025-03-06 09:23:23 -08:00
licenses Harmonize license with apache.org and other Elastic repos 2018-06-19 21:22:38 +00:00
logstash-core Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
logstash-core-plugin-api Don't honor VERSION_QUALIFIER if set but empty (#17032) (#17068) 2025-02-12 16:02:02 +02:00
modules add modules deprecation log for netflow, fb_apache and azure (#16548) 2024-10-14 12:40:45 +01:00
pkg Fix system unit TimeoutStopSec on older version. (#14947) 2023-03-31 14:38:11 -04:00
qa Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
rakelib x-pack: add fips validation plugin from x-pack (#16940) 2025-04-08 09:04:05 -07:00
spec Get tests running in FIPS environment (#17096) 2025-03-04 10:34:36 -08:00
tools Add licenses for bouncycastle fips jars (#17406) 2025-03-31 07:23:19 -07:00
x-pack Improve smoke tests for observability SRE image (#17486) 2025-04-08 13:11:26 -07:00
.dockerignore Introduce docker for CI builds. 2017-09-14 18:55:41 +00:00
.fossa.yml initial introduction of .fossa.yml 2020-07-23 01:38:07 -07:00
.gitignore buildkite serverless test (#15150) 2023-07-19 17:21:53 +01:00
.rubocop.yml Rubocop: Enable most SpaceInside cops (#15201) 2023-07-20 09:49:46 -04:00
.ruby-version Update .ruby-version to jruby-9.4.9.0 (#16642) (#16645) 2024-11-06 12:46:06 +00:00
build.gradle Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
catalog-info.yaml [CI] Change agent for JDK availability check and add schedule also for 8.x (#16614) (#16617) 2024-10-30 12:52:03 +01:00
CONTRIBUTING.md Logstash is logging unnecessary pipeline configuration. (#14779) 2022-12-07 15:11:26 +05:00
CONTRIBUTORS Doc: update contributing guide to include link for IntelliJ setup Fixes #7120 2017-06-19 12:53:40 +00:00
COPYING.csv Add tool to generate dependency details in csv 2017-12-22 16:54:29 +00:00
Gemfile.template Pin rubocop-ast development gem due to new dep on prism (#17407) (#17433) 2025-03-27 08:53:58 -07:00
gradle.properties Increase Gradle network timeouts to increment resiliency on network issues (#14283) 2022-06-21 15:01:08 +02:00
gradlew Update to gradle 8.5 (#15707) 2024-01-02 13:28:34 +01:00
gradlew.bat update multiple dependencies (#16136) 2024-05-08 09:13:41 +01:00
LICENSE.txt Migrate x-pack-logstash source to logstash 2018-04-24 10:46:15 -05:00
NOTICE.TXT Pin fileutils version to 1.7+ (#16250) 2024-06-25 12:14:09 -07:00
Rakefile Add basic ruby linter (#15168) 2023-07-13 17:18:10 -04:00
README.md Replace/remove references to defunct freenode instance (#16873) (#16897) 2025-01-13 09:50:11 -08:00
ROADMAP.md remove overly-broad statements about licensing from docs 2018-03-15 17:48:18 +00:00
rubyUtils.gradle Pull in latests commits from 8.x and update based on new patterns (#17385) 2025-03-21 14:37:08 -07:00
SECURITY.md Create SECURITY.md (#12573) 2021-02-01 10:30:41 +00:00
settings.gradle Move JvmOptionParser to separate project (#13657) 2022-05-18 14:58:53 -04:00
sonar-project.properties [CI] [Sonar] Explicitly specified test sources for sonar (#15954) 2024-02-15 14:10:54 +01:00
STYLE.md use jruby 9.1.9.0 2017-06-12 12:35:10 -04:00
versions.yml upgrade jdk to 21.0.6+7 (#16932) (#16987) 2025-01-30 11:18:35 +00:00

Logstash

Logstash is part of the Elastic Stack along with Beats, Elasticsearch and Kibana. Logstash is a server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to your favorite "stash." (Ours is Elasticsearch, naturally.). Logstash has over 200 plugins, and you can write your own very easily as well.

For more info, see https://www.elastic.co/products/logstash

Documentation and Getting Started

You can find the documentation and getting started guides for Logstash on the elastic.co site

For information about building the documentation, see the README in https://github.com/elastic/docs

Downloads

You can download officially released Logstash binaries, as well as debian/rpm packages for the supported platforms, from downloads page.

Need Help?

Logstash Plugins

Logstash plugins are hosted in separate repositories under the logstash-plugins github organization. Each plugin is a self-contained Ruby gem which gets published to RubyGems.org.

Writing your own Plugin

Logstash is known for its extensibility. There are hundreds of plugins for Logstash and you can write your own very easily! For more info on developing and testing these plugins, please see the working with plugins section

Plugin Issues and Pull Requests

Please open new issues and pull requests for plugins under its own repository

For example, if you have to report an issue/enhancement for the Elasticsearch output, please do so here.

Logstash core will continue to exist under this repository and all related issues and pull requests can be submitted here.

Developing Logstash Core

Prerequisites

  • Install JDK version 11 or 17. Make sure to set the JAVA_HOME environment variable to the path to your JDK installation directory. For example set JAVA_HOME=<JDK_PATH>
  • Install JRuby 9.2.x It is recommended to use a Ruby version manager such as RVM or rbenv.
  • Install rake and bundler tool using gem install rake and gem install bundler respectively.

RVM install (optional)

If you prefer to use rvm (ruby version manager) to manage Ruby versions on your machine, follow these directions. In the Logstash folder:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --ruby=$(cat .ruby-version)

Check Ruby version

Before you proceed, please check your ruby version by:

$ ruby -v

The printed version should be the same as in the .ruby-version file.

Building Logstash

The Logstash project includes the source code for all of Logstash, including the Elastic-Licensed X-Pack features and functions; to run Logstash from source using only the OSS-licensed code, export the OSS environment variable with a value of true:

export OSS=true
  • Set up the location of the source code to build
export LOGSTASH_SOURCE=1
export LOGSTASH_PATH=/YOUR/LOGSTASH/DIRECTORY
  • Install development dependencies
./gradlew installDevelopmentGems
  • Install default plugins and other dependencies
./gradlew installDefaultGems

Verify the installation

To verify your environment, run the following to start Logstash and send your first event:

bin/logstash -e 'input { stdin { } } output { stdout {} }'

This should start Logstash with stdin input waiting for you to enter an event

hello world
2016-11-11T01:22:14.405+0000 0.0.0.0 hello world

Advanced: Drip Launcher

Drip is a tool that solves the slow JVM startup problem while developing Logstash. The drip script is intended to be a drop-in replacement for the java command. We recommend using drip during development, in particular for running tests. Using drip, the first invocation of a command will not be faster but the subsequent commands will be swift.

To tell logstash to use drip, set the environment variable JAVACMD=`which drip`.

Example (but see the Testing section below before running rspec for the first time):

JAVACMD=`which drip` bin/rspec

Caveats

Drip does not work with STDIN. You cannot use drip for running configs which use the stdin plugin.

Building Logstash Documentation

To build the Logstash Reference (open source content only) on your local machine, clone the following repos:

logstash - contains main docs about core features

logstash-docs - contains generated plugin docs

docs - contains doc build files

Make sure you have the same branch checked out in logstash and logstash-docs. Check out master in the docs repo.

Run the doc build script from within the docs repo. For example:

./build_docs.pl --doc ../logstash/docs/index.asciidoc --chunk=1 -open

Testing

Most of the unit tests in Logstash are written using rspec for the Ruby parts. For the Java parts, we use junit. For testing you can use the test rake tasks and the bin/rspec command, see instructions below:

Core tests

1- To run the core tests you can use the Gradle task:

./gradlew test

or use the rspec tool to run all tests or run a specific test:

bin/rspec
bin/rspec spec/foo/bar_spec.rb

Note that before running the rspec command for the first time you need to set up the RSpec test dependencies by running:

./gradlew bootstrap

2- To run the subset of tests covering the Java codebase only run:

./gradlew javaTests

3- To execute the complete test-suite including the integration tests run:

./gradlew check

4- To execute a single Ruby test run:

SPEC_OPTS="-fd -P logstash-core/spec/logstash/api/commands/default_metadata_spec.rb" ./gradlew :logstash-core:rubyTests --tests org.logstash.RSpecTests

5- To execute single spec for integration test, run:

./gradlew integrationTests -PrubyIntegrationSpecs=specs/slowlog_spec.rb

Sometimes you might find a change to a piece of Logstash code causes a test to hang. These can be hard to debug.

If you set LS_JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" you can connect to a running Logstash with your IDEs debugger which can be a great way of finding the issue.

Plugins tests

To run the tests of all currently installed plugins:

rake test:plugins

You can install the default set of plugins included in the logstash package:

rake test:install-default

Note that if a plugin is installed using the plugin manager bin/logstash-plugin install ... do not forget to also install the plugins development dependencies using the following command after the plugin installation:

bin/logstash-plugin install --development

Building Artifacts

Built artifacts will be placed in the LS_HOME/build directory, and will create the directory if it is not already present.

You can build a Logstash snapshot package as tarball or zip file

./gradlew assembleTarDistribution
./gradlew assembleZipDistribution

OSS-only artifacts can similarly be built with their own gradle tasks:

./gradlew assembleOssTarDistribution
./gradlew assembleOssZipDistribution

You can also build .rpm and .deb, but the fpm tool is required.

rake artifact:rpm
rake artifact:deb

and:

rake artifact:rpm_oss
rake artifact:deb_oss

Using a Custom JRuby Distribution

If you want the build to use a custom JRuby you can do so by setting a path to a custom JRuby distribution's source root via the custom.jruby.path Gradle property.

E.g.

./gradlew clean test -Pcustom.jruby.path="/path/to/jruby"

Project Principles

  • Community: If a newbie has a bad time, it's a bug.
  • Software: Make it work, then make it right, then make it fast.
  • Technology: If it doesn't do a thing today, we can make it do it tomorrow.

Contributing

All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.

Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.

It is more important that you are able to contribute.

For more information about contributing, see the CONTRIBUTING file.

Footnotes


  1. Use bundle instead of gradle to install dependencies

    Alternatively, instead of using gradle you can also use bundle:

    • Install development dependencies

      bundle config set --local path vendor/bundle
      bundle install
      
    • Bootstrap the environment:

      rake bootstrap
      
    • You can then use bin/logstash to start Logstash, but there are no plugins installed. To install default plugins, you can run:

      rake plugin:install-default
      

    This will install the 80+ default plugins which makes Logstash ready to connect to multiple data sources, perform transformations and send the results to Elasticsearch and other destinations.

    ↩︎