Enterprises typically generate large volumes of service logs (in JSON or CSV formats), often distributed across local servers or third-party cloud platforms. For centralized search and real-time analytics, you may choose to aggregate such data into CSS OpenSearch clusters. However, for security reasons, CSS clusters are frequently deployed within private networks (for example, VPCs), which restrict direct ingestion from external data sources. This topic describes how to use open-source Logstash to securely and efficiently ingest data into CSS clusters in both private and public network environments.
Logstash is an open-source, server-side data processing pipeline that ingests data from multiple sources simultaneously, processes and transforms the data, and then sends it to CSS clusters. For more information about Logstash, see the official document Getting started with Logstash.
Depending on where the Logstash server is deployed, this solution can use either of the following network architectures:
Logstash is deployed on an ECS that is in the same VPC as the destination CSS cluster.
Characteristics: fast, easy to set up, and secure.
Figure 1 Logstash and CSS within the same VPC

Logstash is deployed in an on-premises data center or on a server located on the public network, which prevents it from directly accessing the destination CSS cluster in a private network. To connect the two, we need to use an ECS allocated with a public IP address as a jump server. This jump server leverages SSH port forwarding to forward traffic coming from Logstash to the destination cluster on the cloud.
Characteristics: suitable for migrating on-premises data to the cloud; port forwarding must be configured. Figure 2 Logstash deployed on premises or in the public network
Download Logstash OSS at https://www.elastic.co/downloads/past-releases?product=logstash-oss.
For example, the access_20181029.log is already in the /tmp/access_log/ directory on the Logstash server. The following is an example of the data:
Ping the CSS cluster's private network address from the ECS where you plan to deploy Logstash. If successful, the two are connected.
yum install java # Replace it with the actual JDK version.
yum install logstash-oss-7.10.0-x86_64.rpm
Replace logstash-oss-7.10.0-x86_64.rpm with the actual Logstash installation package name.
The default heap memory of Logstash is 1 GB. You are advised to change it to half the cluster node memory.
vim /etc/logstash/jvm.options-Xms4g-Xmx4g
cd /logstash-x.x/ # Go to the Logstash installation directory.vi logstash-simple.conf # Create a configuration file.
input {# Read local log files.file {path => "/tmp/access_log/*.log" # Path to the log filesstart_position => "beginning" # Start position for reading data}}filter {# Add data filtering logic here, such as grok and mutate.}output {elasticsearch {# Enter the cluster's private network address. For a multi-cluster node, enter multiple addresses to allow for load balancing.hosts => ["192.168.xxx.xxx:9200", "192.168.xxx.xxx:9200"]# Name of the index that events are written to.index => "my_import_index"# Configure the following for a security-mode cluster. (Delete them if security mode is disabled.)# user => "username" # CSS cluster account# password => "password" # CSS cluster password# ssl => true # Whether SSL is enabled# ssl_certificate_verification => false # Whether to enable certificate authentication# cacert => "/logstash/config/CloudSearchService.cer" # Absolute path to the security certificate# Commonly configured parameters to mitigate compatibility issuesilm_enabled => false # Disable index lifecycle management to prevent permission errors.manage_template => false # Disable template management.}}
./bin/logstash -f logstash-simple.conf # Replace the file name with the actual configuration file name.
If a message similar to Successfully started Logstash API endpoint is returned and no error is reported, the task is running properly.
The left part of the console is the command input box, and the triangle icon in its upper-right corner is the execution button. The right part shows the execution result.
GET my_import_index/_count # Check the number of records ingested.GET my_import_index/_search # Check the content of the ingested data.
If the results are consistent with the source, data ingestion is successful.
ssh -g -L <Local port on the jump server>:<Private IP address of a CSS cluster node>:9200 -N -f root@<The jump server's private network address>
For example, if the opened local port (allowed by security group rules) on the jump server is 9100, the CSS cluster node's private IP address is 192.168.0.81, and the jump server's private IP address is 192.168.0.227, the port mapping command is as follows:
ssh -g -L 9100:192.168.0.81:9200 -N -f root@192.168.0.227
If the specified CSS cluster node is unavailable, the port mapping command will fail. If the cluster contains multiple nodes, replace <Private IP address of a CSS cluster node> with the IP address of another node. If the cluster contains only one node, you have to wait until the node recovers.
For more information about SSH tunneling, see SSH official documents.
curl http://<The jump server's public IP address>:<The jump server's local port>
If the OpenSearch version information is returned, the tunnel is established. When you configure the Logstash configuration file later, set hosts to <The jump server's public IP address>:<The jump server's local port>.
yum install java # Replace it with the actual JDK version.
yum install logstash-oss-7.10.0-x86_64.rpm
Replace logstash-oss-7.10.0-x86_64.rpm with the actual Logstash installation package name.
The default heap memory of Logstash is 1 GB. You are advised to change it to half the cluster node memory.
vim /etc/logstash/jvm.options-Xms4g-Xmx4g
cd /logstash-x.x/ # Go to the Logstash installation directory.vi logstash-simple.conf # Create a configuration file.
input {# Read local log files.file {path => "/tmp/access_log/*.log" # Path to the log filesstart_position => "beginning" # Start position for reading data}}filter {# Add data filtering logic here, such as grok and mutate.}output {elasticsearch {# Enter the local address for the SSH tunnel.hosts => ["<The jump server's public IP address>:<The jump server's local port>"]# Name of the index that events are written to.index => "my_import_index"# Configure the following for a security-mode cluster. (Delete them if security mode is disabled.)# user => "username" # CSS cluster account# password => "password" # CSS cluster password# ssl => true # Whether SSL is enabled# ssl_certificate_verification => false # Whether to enable certificate authentication# cacert => "/logstash/config/CloudSearchService.cer" # Absolute path to the security certificate# Commonly configured parameters to mitigate compatibility issuesilm_enabled => false # Disable index lifecycle management to prevent permission errors.manage_template => false # Disable template management.}}
./bin/logstash -f logstash-simple.conf # Replace the file name with the actual configuration file name.
If a message similar to Successfully started Logstash API endpoint is returned and no error is reported, the task is running properly.
The left part of the console is the command input box, and the triangle icon in its upper-right corner is the execution button. The right part shows the execution result.
GET my_import_index/_count # Check the number of records ingested.GET my_import_index/_search # Check the content of the ingested data.
If the results are consistent with the source, data ingestion is successful.
To access a security-mode OpenSearch cluster that uses HTTPS, perform the following steps to obtain the security certificate CloudSearchService.cer if it is required.