How to Install Logstash

How to Install Logstash Logstash is a powerful, open-source data processing pipeline that ingests data from multiple sources simultaneously, transforms it, and sends it to your preferred destination. Whether you’re collecting server logs, application metrics, or network traffic data, Logstash plays a critical role in modern observability and monitoring stacks. Often paired with Elasticsearch and K

Oct 30, 2025 - 12:33
Oct 30, 2025 - 12:33
 0

How to Install Logstash

Logstash is a powerful, open-source data processing pipeline that ingests data from multiple sources simultaneously, transforms it, and sends it to your preferred destination. Whether youre collecting server logs, application metrics, or network traffic data, Logstash plays a critical role in modern observability and monitoring stacks. Often paired with Elasticsearch and Kibana as part of the Elastic Stack (formerly ELK Stack), Logstash enables organizations to centralize, analyze, and visualize massive volumes of structured and unstructured data in near real-time.

Installing Logstash correctly is the foundation of any successful log management or data ingestion strategy. A misconfigured or improperly installed instance can lead to data loss, performance bottlenecks, or security vulnerabilities. This guide provides a comprehensive, step-by-step walkthrough of how to install Logstash across multiple operating systems, including best practices, real-world use cases, and essential tools to ensure a robust, scalable deployment.

By the end of this tutorial, youll understand not only how to install Logstash, but also how to configure it for production-grade reliability, optimize performance, and troubleshoot common issues. This is not just a tutorialits your blueprint for deploying Logstash with confidence.

Step-by-Step Guide

Prerequisites

Before installing Logstash, ensure your system meets the following requirements:

  • Java Runtime Environment (JRE) 11 or higher Logstash is built on Java and requires a compatible JVM to run.
  • Minimum 2 GB RAM While Logstash can run on lower memory, production environments require at least 4 GB.
  • At least 2 CPU cores For optimal performance, especially with high-throughput pipelines.
  • Internet access Required to download packages and plugins.
  • Administrative privileges Installation typically requires root or sudo access.

Verify your Java installation by running:

java -version

If Java is not installed, download and install OpenJDK 11 or 17 from your OSs package manager or the Adoptium project.

Installing Logstash on Ubuntu/Debian

Ubuntu and Debian are among the most popular Linux distributions for server deployments. Follow these steps to install Logstash on these systems:

  1. Import the Elastic GPG key

    To ensure package integrity, import the official Elastic signing key:

    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

  2. Add the Elastic repository

    Add the Elastic APT repository to your systems sources list:

    echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list

  3. Update package index

    Refresh your package list to include the new repository:

    sudo apt-get update

  4. Install Logstash

    Install the latest stable version of Logstash:

    sudo apt-get install logstash

  5. Start and enable the service

    Start Logstash and configure it to launch at boot:

    sudo systemctl start logstash
    

    sudo systemctl enable logstash

  6. Verify installation

    Check the service status to confirm Logstash is running:

    sudo systemctl status logstash

If the service is active and running, Logstash is successfully installed on your Ubuntu/Debian system.

Installing Logstash on CentOS/RHEL/Fedora

For Red Hat-based distributions, Logstash can be installed using the YUM or DNF package managers. The process is similar to Debian but uses RPM packages.

  1. Import the Elastic GPG key

    Add the Elastic signing key to your system:

    rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

  2. Create the Elastic repository file

    Create a new repository configuration file:

    sudo vi /etc/yum.repos.d/elastic-8.x.repo

  3. Add the following content:

    [elastic-8.x]
    

    name=Elastic repository for 8.x packages

    baseurl=https://artifacts.elastic.co/packages/8.x/yum

    gpgcheck=1

    gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch

    enabled=1

    autorefresh=1

    type=rpm-md

  4. Install Logstash

    Use YUM (for CentOS 7/RHEL 7) or DNF (for CentOS 8+/RHEL 8+/Fedora):

    sudo yum install logstash

    or

    sudo dnf install logstash

  5. Start and enable the service
    sudo systemctl start logstash
    

    sudo systemctl enable logstash

  6. Verify installation

    Confirm the service is running:

    sudo systemctl status logstash

Once confirmed, you can proceed to configuration.

Installing Logstash on macOS

macOS users can install Logstash via Homebrew, the most popular package manager for macOS.

  1. Install Homebrew (if not already installed)

    Run the following command in Terminal:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  2. Install Logstash

    Use Homebrew to install the latest version:

    brew install logstash

  3. Start Logstash manually

    Logstash does not run as a system service by default on macOS. Start it via:

    logstash

  4. Verify installation

    You should see Logstash initializing and loading plugins. To run Logstash as a background service, use:

    brew services start logstash

Installing Logstash on Windows

Windows installations require a manual download and configuration process.

  1. Download Logstash

    Visit the official Logstash downloads page and select the Windows .zip file.

  2. Extract the archive

    Extract the downloaded ZIP file to a directory such as C:\logstash. Avoid paths with spaces (e.g., C:\Program Files\).

  3. Verify Java installation

    Open Command Prompt and run:

    java -version

    If Java is not found, download and install OpenJDK 11 or 17 from Adoptium.

  4. Configure environment variables (optional but recommended)

    Add the Logstash bin directory to your system PATH:

    • Right-click This PC ? Properties ? Advanced System Settings ? Environment Variables
    • Add C:\logstash\bin to the PATH variable.

  5. Test Logstash

    Open Command Prompt and run a simple test:

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

    Type a message and press Enter. If you see the message appear in the output, Logstash is working.

  6. Install Logstash as a Windows Service (optional)

    To run Logstash as a background service, navigate to the bin directory and run:

    logstash-service install

    Then start it:

    net start logstash-service

Basic Configuration and First Pipeline

Logstash configurations are stored in the config directory. On Linux, this is typically /etc/logstash/. On Windows, its C:\logstash\config\.

Create your first pipeline configuration file:

sudo nano /etc/logstash/conf.d/01-simple.conf

Add the following basic configuration:

input {

stdin { }

}

output {

stdout { codec => rubydebug }

}

This configuration tells Logstash to read input from the terminal (stdin) and output formatted data to the console.

Test the configuration before starting:

sudo /usr/share/logstash/bin/logstash --path.settings /etc/logstash -t

If the output says Configuration OK, start Logstash:

sudo systemctl restart logstash

Now, type a message in the terminal where Logstash is running. You should see structured JSON output in the console.

Best Practices

Use Separate Configuration Files

Never place all your pipeline configurations in a single file. Instead, organize them into multiple files under the conf.d/ directory, named in numerical order (e.g., 01-input.conf, 02-filter.conf, 03-output.conf). This improves readability, maintainability, and enables modular updates.

Validate Configurations Before Restarting

Always validate your configuration files before restarting Logstash:

sudo /usr/share/logstash/bin/logstash --path.settings /etc/logstash -t

This prevents service downtime due to syntax errors. A single misplaced bracket or misspelled plugin name can cause Logstash to fail to start.

Optimize Memory Allocation

Logstash runs on the JVM and is memory-intensive. Edit the JVM options file:

sudo nano /etc/logstash/jvm.options

Adjust heap size based on available RAM:

-Xms2g

-Xmx2g

For systems with 8 GB RAM or more, consider allocating 4 GB: -Xms4g -Xmx4g. Avoid setting heap size larger than 50% of total system RAM.

Enable Logging and Monitoring

Logstash logs are stored in /var/log/logstash/ on Linux. Monitor these logs for errors:

tail -f /var/log/logstash/logstash-plain.log

Enable the monitoring feature in logstash.yml to send internal metrics to Elasticsearch:

xpack.monitoring.enabled: true

xpack.monitoring.elasticsearch.hosts: ["http://localhost:9200"]

This allows you to visualize Logstash performance in Kibanas Monitoring UI.

Use Pipeline Workers Wisely

The number of pipeline workers determines how many events can be processed in parallel. Set this based on CPU cores:

pipeline.workers: 4

By default, Logstash sets this to the number of CPU cores. For high-throughput environments, you can increase it, but monitor CPU usage to avoid overloading.

Secure Your Installation

If Logstash communicates with Elasticsearch or other services over the network:

  • Use HTTPS and TLS for encrypted communication.
  • Enable authentication using API keys or basic auth.
  • Restrict firewall access to only trusted IP addresses.
  • Never expose Logstash ports (e.g., 5044, 9600) directly to the public internet.

Configure TLS in your output plugin:

output {

elasticsearch {

hosts => ["https://your-elasticsearch:9200"]

ssl => true

ssl_certificate_verification => true

user => "logstash_writer"

password => "your_secure_password"

}

}

Use Filebeat or Fluentd for Log Collection

While Logstash can read files directly using the file input plugin, its not optimized for high-volume, real-time log collection. Use Filebeat (for logs) or Fluentd (for multi-source data) to ship logs to Logstash. This decouples collection from processing, improves reliability, and reduces resource load on Logstash.

Regularly Update Logstash

Keep Logstash updated to benefit from performance improvements, bug fixes, and security patches. Use your package manager:

sudo apt-get update && sudo apt-get upgrade logstash

Always test updates in a staging environment before deploying to production.

Tools and Resources

Essential Logstash Plugins

Logstashs power lies in its plugin ecosystem. Install plugins using the logstash-plugin command:

sudo /usr/share/logstash/bin/logstash-plugin install logstash-filter-grok

sudo /usr/share/logstash/bin/logstash-plugin install logstash-filter-date

sudo /usr/share/logstash/bin/logstash-plugin install logstash-output-elasticsearch

Key plugins for production use:

  • grok Parse unstructured log data into structured fields using patterns.
  • date Parse timestamps from log messages and assign them to the @timestamp field.
  • mutate Rename, remove, or modify fields.
  • geoip Enrich IP addresses with geographic data.
  • json Parse JSON-formatted messages.
  • elasticsearch Output data to Elasticsearch.
  • file Read from log files (use only with Filebeat for high volume).
  • beats Receive data from Filebeat.

Logstash Configuration Validator

Use the built-in configuration tester before every restart:

logstash --path.settings /etc/logstash -t

It checks syntax, plugin availability, and configuration validity.

Logstash Documentation and Examples

Official resources:

Monitoring Tools

Monitor Logstash performance using:

  • Kibana Monitoring Built-in dashboard for pipeline throughput, JVM metrics, and errors.
  • Prometheus + Grafana Export Logstash metrics via the HTTP endpoint (port 9600) and visualize in Grafana.
  • System Monitoring Use htop, iotop, or netstat to monitor CPU, memory, disk I/O, and network usage.

Containerized Deployment (Docker)

For modern infrastructure, deploy Logstash in Docker containers:

docker run -d --name=logstash \

-p 5044:5044 \

-p 9600:9600 \

-v /path/to/config:/usr/share/logstash/pipeline \

-v /path/to/logs:/var/log/logstash \

docker.elastic.co/logstash/logstash:8.12.0

Use Docker Compose for multi-service setups with Elasticsearch and Kibana.

CI/CD Integration

Integrate Logstash configuration management into your DevOps pipeline:

  • Store configurations in Git repositories.
  • Use tools like Ansible, Terraform, or Puppet for automated deployment.
  • Run configuration validation as part of your CI pipeline.

Real Examples

Example 1: Centralized Web Server Log Aggregation

Scenario: You have 10 web servers running Nginx. You want to collect access logs, parse them, and send them to Elasticsearch for analysis.

Step 1: Install Filebeat on each web server

Configure /etc/filebeat/filebeat.yml:

filebeat.inputs:

- type: filestream

enabled: true

paths:

- /var/log/nginx/access.log

output.logstash:

hosts: ["logstash-server:5044"]

Step 2: Configure Logstash Pipeline

Create /etc/logstash/conf.d/10-nginx.conf:

input {

beats {

port => 5044

}

}

filter {

grok {

match => { "message" => "%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] \"%{WORD:method} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}\" %{NUMBER:response} (?:%{NUMBER:bytes}|-)" }

}

date {

match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]

target => "@timestamp"

}

geoip {

source => "clientip"

}

mutate {

remove_field => [ "message", "host", "agent", "offset" ]

}

}

output {

elasticsearch {

hosts => ["http://elasticsearch:9200"]

index => "nginx-access-%{+YYYY.MM.dd}"

document_type => "_doc"

}

}

This pipeline parses Nginx access logs, extracts client IP, request method, response code, and geolocates the IP. It then indexes the data into daily Elasticsearch indices.

Example 2: Application Error Log Monitoring

Scenario: Youre running a Java Spring Boot application that writes structured JSON logs to a file. You want to ingest these logs and extract error levels, stack traces, and timestamps.

Log Sample:

{"timestamp":"2024-05-10T12:34:56.789Z","level":"ERROR","logger":"com.example.Service","message":"Database connection failed","stack_trace":"java.sql.SQLException: ...","host":"app-server-01"}

Logstash Configuration:

input {

file {

path => "/opt/app/logs/application.log"

start_position => "beginning"

codec => "json"

}

}

filter {

date {

match => [ "timestamp", "ISO8601" ]

target => "@timestamp"

}

mutate {

rename => { "level" => "log_level" }

remove_field => [ "timestamp", "host" ]

}

}

output {

elasticsearch {

hosts => ["http://elasticsearch:9200"]

index => "app-errors-%{+YYYY.MM.dd}"

document_type => "_doc"

}

stdout { codec => rubydebug }

}

This configuration automatically parses the JSON structure without requiring grok patterns, making it efficient and reliable.

Example 3: Syslog Aggregation from Network Devices

Scenario: Collect syslog messages from routers, switches, and firewalls.

Logstash Configuration:

input {

syslog {

port => 5140

type => "network-syslog"

}

}

filter {

if [type] == "network-syslog" {

grok {

match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }

}

date {

match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]

target => "@timestamp"

}

}

}

output {

elasticsearch {

hosts => ["http://elasticsearch:9200"]

index => "network-syslog-%{+YYYY.MM.dd}"

}

}

Configure your network devices to forward syslog to Logstashs IP on port 5140.

FAQs

Can Logstash run without Elasticsearch?

Yes. Logstash can output to many destinations: files, databases (PostgreSQL, MySQL), Kafka, Amazon S3, or even stdout for debugging. Elasticsearch is optional but commonly used for search and visualization.

How much memory does Logstash need?

For development: 2 GB RAM. For production: 48 GB depending on throughput. Monitor JVM heap usage via Kibana or Prometheus to avoid out-of-memory errors.

Why is Logstash using so much CPU?

High CPU usage typically results from complex grok patterns, large volumes of unstructured data, or insufficient pipeline workers. Optimize filters, use Filebeat for log collection, and increase workers if CPU cores are underutilized.

Can I run multiple Logstash instances on one server?

Yes, but each instance must use unique ports (input, output, HTTP monitoring). Use different config directories and systemd service files. Not recommended unless necessaryconsider using multiple pipelines within one instance instead.

How do I upgrade Logstash without losing data?

Logstash does not store datait processes and forwards it. Back up your configuration files. Stop the service, install the new version, validate the config, then restart. Ensure downstream systems (Elasticsearch, Kafka) are compatible with the new version.

Whats the difference between Logstash and Fluentd?

Both are data collectors, but Logstash is more feature-rich with built-in filters and integrations. Fluentd is lighter and written in Ruby/C, often preferred in Kubernetes environments. Use Logstash for complex transformations; use Fluentd for lightweight, high-performance ingestion.

How do I troubleshoot a failing Logstash pipeline?

Check /var/log/logstash/logstash-plain.log for errors. Use logstash -t to validate config. Test inputs with stdin and stdout first. Use the rubydebug codec to inspect event structure.

Is Logstash secure by default?

No. By default, Logstash listens on unencrypted ports and has no authentication. Always enable TLS, restrict access via firewall, and use authentication when connecting to Elasticsearch or other services.

Can Logstash process real-time data streams?

Yes. With inputs like Beats, Kafka, or TCP/UDP, Logstash can ingest and transform data in real time. For ultra-low-latency needs, consider using Kafka with a lightweight consumer, but Logstash is suitable for most real-time analytics use cases.

What happens if Elasticsearch is down?

Logstash will retry sending events based on its output plugin configuration. By default, it retries indefinitely. To prevent memory buildup, configure queue settings or use a dead-letter queue (DLQ) to store failed events for later processing.

Conclusion

Installing Logstash is more than just running an installerits the beginning of a robust, scalable data processing architecture. Whether youre ingesting server logs, application metrics, or network telemetry, the steps outlined in this guide ensure a secure, efficient, and maintainable deployment.

By following best practicesorganizing configurations, validating pipelines, optimizing memory, securing endpoints, and integrating with Filebeatyou transform Logstash from a simple tool into a mission-critical component of your observability stack.

Remember: Logstash is not a one-size-fits-all solution. Its true power emerges when combined with the right inputs, filters, outputs, and monitoring tools. Use the real-world examples provided to adapt this guide to your unique environment. Test thoroughly, monitor continuously, and iterate based on performance metrics.

With this knowledge, youre no longer just installing Logstashyoure architecting data pipelines that empower smarter decisions, faster troubleshooting, and deeper insights across your entire infrastructure.