Deployment guide

ELK Stack

Overview

The ELK Stack combines three open source tools: Elasticsearch for search and analytics, Logstash for data ingestion and transformation, and Kibana for data visualization and dashboards.

This guide covers deploying and configuring the ELK Stack on Linux from the SecureAnyCloud AMIs on the AWS Marketplace. The image ships with security enabled and generated credentials.

What you get:

  • Elasticsearch 8.6.1 with security enabled (HTTPS and authentication)
  • Logstash for log parsing and data pipeline processing
  • Kibana dashboard on port 5601
  • Java runtime environment
  • Preconfigured security with auto-generated credentials
  • OS package update script for keeping the system current
  • AWS CLI v2 for AWS service integration
  • Systems Manager Agent (SSM) for remote management
  • CloudWatch Agent for monitoring
  • Latest security patches applied at build time
  • 24/7 SecureAnyCloud support with a guaranteed 24-hour response SLA

Prerequisites

Before you launch this AMI, make sure you have:

  • An active AWS account
  • An active subscription to the ELK Stack listing on AWS Marketplace
  • An EC2 key pair for SSH access
  • Familiarity with EC2 instance management and SSH

Recommended instance type: t3.large (2 vCPU, 8 GB RAM) or larger. The minimum is 1 vCPU, 1 GB RAM and 20 GB of disk space. Elasticsearch is memory-intensive and performs significantly better with 8 GB or more.

1

Launch the AMI

  • Go to the AWS Marketplace and search for "ELK Stack SecureAnyCloud"
  • Choose Continue to Subscribe, accept the terms, then choose Continue to Configuration
  • Select your preferred Region and Software Version
  • Choose Continue to Launch
  • Choose Launch through EC2 for full control over instance configuration
  • Select your instance type (t3.large recommended)
  • Configure storage: 20 GB gp3 minimum, and 50 GB or more recommended for production log storage
  • Configure your Security Group with the inbound rules listed below
  • Select your EC2 key pair and launch the instance

Add these inbound rules to the security group:

  • Port 22, TCP, from your IP: SSH access
  • Port 9200, TCP, from your IP: Elasticsearch API calls over HTTP
  • Port 5601, TCP, from your IP: Kibana dashboard

Important: Restrict ports 9200 and 5601 to trusted IP addresses only. These services provide access to your data and should not be exposed to the public internet.

2

Connect via SSH

Once your instance is running and has passed both status checks (2/2), connect over SSH:

ssh -i your-key.pem ec2-user@<public-ip-address>

Replace your-key.pem with the path to your EC2 key pair and <public-ip-address> with your instance's public IP.

Important: Wait for the EC2 instance to reach 2/2 successful status checks before you connect. If you connect too early, you may see errors such as:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

To switch to the root user:

sudo su -
3

Retrieve credentials

The ELK Stack is preconfigured with security enabled. Randomly generated credentials are stored in log files on the instance. Read them as follows.

Elasticsearch credentials:

cat /stage/scripts/elastic_password.log

Kibana credentials:

cat /stage/scripts/kibana_password.log

Important: Make a note of these passwords. You will need them to access Elasticsearch and Kibana.

4

Verify Elasticsearch

Check that Elasticsearch is running and responding to API requests:

curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic http://localhost:9200

Enter the password from the elastic_password.log file when prompted.

Expected output:

{ "name" : "ip-172-31-89-117.ec2.internal", "cluster_name" : "elasticsearch", "cluster_uuid" : "wdyXEmS-TEearSUr0MEhPA", "version" : { "number" : "8.6.1", "build_flavor" : "default", "build_type" : "rpm", "lucene_version" : "9.4.2", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" }
5

Access Kibana

Open your web browser and go to:

http://<public-ip-address>:5601

You will see the Kibana login screen. Sign in with:

  • Username: elastic
  • Password: The value from /stage/scripts/elastic_password.log

After you sign in, the Kibana home page opens. From there you can add integrations, create dashboards and explore your data.

Server components

The components are installed at these paths:

  • Java: /bin/java
  • Elasticsearch: /var/lib/elasticsearch
  • Logstash: /etc/logstash
  • Kibana: /etc/kibana

Note: The automatic OS package update script may update component versions on first boot.

Filesystem layout

The instance has these mount points:

  • / (38 GB): root filesystem
  • /boot (2 GB): operating system kernel files
  • /var/lib/elasticsearch (9.8 GB): Elasticsearch data and indices

Key directories:

  • /etc/elasticsearch: Elasticsearch configuration
  • /var/lib/elasticsearch: Elasticsearch data (indices, shards)
  • /var/log/elasticsearch: Elasticsearch logs
  • /etc/logstash: Logstash configuration
  • /etc/logstash/conf.d: Logstash pipeline configurations
  • /var/log/logstash: Logstash logs
  • /etc/kibana: Kibana configuration
  • /var/log/kibana: Kibana logs
  • /etc/elasticsearch/certs: TLS certificates for Elasticsearch

Manage services

systemd manages all three services, and they start automatically on boot.

Elasticsearch:

systemctl start elasticsearch
systemctl stop elasticsearch
systemctl status elasticsearch

Logstash:

systemctl start logstash
systemctl stop logstash
systemctl status logstash

Kibana:

systemctl start kibana
systemctl stop kibana
systemctl status kibana

Scripts and log files

These files live in /stage/scripts:

  • initial_boot_update.sh: updates the OS with the latest packages on first boot
  • initial_boot_update.log: output log for the boot update script
  • elastic_password.log: Elasticsearch user credentials
  • kibana_password.log: Kibana system user credentials

On startup

An OS package update script runs on first boot so that the image is fully up to date. To disable it, remove the script and its crontab entry:

rm -f /stage/scripts/initial_boot_update.sh crontab -e
# Delete the following line, save and exit: @reboot /stage/scripts/initial_boot_update.sh

Configure Logstash pipelines

To ingest logs, create pipeline configuration files in /etc/logstash/conf.d/.

Example: Ingest syslog data

Create /etc/logstash/conf.d/syslog.conf:

input { file { path => "/var/log/messages" start_position => "beginning" type => "syslog" } } filter { grok { match => { "message" => "%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST:host} %{DATA:program}: %{GREEDYDATA:message}" } } } output { elasticsearch { hosts => ["https://localhost:9200"] user => "elastic" password => "YOUR_ELASTIC_PASSWORD" ssl_certificate_authorities => "/etc/elasticsearch/certs/http_ca.crt" index => "syslog-%{+YYYY.MM.dd}" } }

Restart Logstash to apply the new pipeline:

systemctl restart logstash

Troubleshooting

Cannot access Kibana on port 5601

  • Verify that Kibana is running: systemctl status kibana
  • Check that your security group allows port 5601 from your IP
  • Kibana may take 1 to 2 minutes to start. Wait and retry.
  • Check Kibana logs: tail -f /var/log/kibana/kibana.log

Elasticsearch returns authentication errors

  • Verify that you are using the correct password from /stage/scripts/elastic_password.log
  • Use the --cacert flag when you make API calls with curl
  • Reset the elastic password if needed: bash /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic

Elasticsearch cluster health is yellow or red

  • Check cluster health: curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic http://localhost:9200/_cluster/health?pretty
  • Yellow status with a single node is normal, because replicas cannot be allocated
  • Red status indicates unassigned primary shards. Check disk space and logs.

Logstash pipeline is not processing data

  • Verify that Logstash is running: systemctl status logstash
  • Check pipeline configuration syntax: /usr/share/logstash/bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/
  • Review Logstash logs: tail -f /var/log/logstash/logstash-plain.log

Security Recommendations

  • Change the generated passwords: Reset the Elasticsearch and Kibana passwords after your first login
  • Restrict network access: Only allow ports 9200 and 5601 from trusted IPs
  • Enable HTTPS for Kibana: Configure TLS in /etc/kibana/kibana.yml for encrypted access
  • Use role-based access control: Create dedicated users with minimal privileges in Kibana
  • Secure credential files: Delete /stage/scripts/elastic_password.log and kibana_password.log after you note the passwords
  • Monitor cluster health: Set up alerts for cluster status changes
  • Back up indices: Use Elasticsearch snapshots to S3 for disaster recovery
  • Keep the stack updated: Regularly update all components with yum update

Support

If you run into any issue with this product, contact SecureAnyCloud support:

  • Email: sales@secureanycloud.com
  • Website: secureanycloud.com
  • Support hours: 24/7 with a guaranteed 24-hour response SLA

Deploy on AWS

Launch ELK Stack with 24/7 support from SecureAnyCloud.

View on Marketplace

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on AWS

Launch ELK Stack with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com