Logstash keeps restarting after clean install // Ubuntu 18.04 + Java 11

Steps to reproduce error:

prerequisites: a clean install of Ubuntu 18.04 (I am running on Ec2)

Step 1) $ sudo apt-get update
Step 2) $ java -version

Command 'java' not found, but can be installed with:

sudo apt install default-jre            
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless 

Step 3) $ sudo apt install default-jre
Step 4) $ java -version

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)

Step 5) export JAVA_HOME environment per the RPM installation guide here

$ sudo vim /etc/profile

# ...
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin;export JAVA_HOME;export JRE_HOME;export PATH

Step 6) reboot the OS for good measure $ sudo reboot
Step 7) create a generic *.conf file so logstash wont complain that it doesnt find one when it starts
$ cd /etc/logstash/conf.d
$ sudo touch basic.conf
$ sudo vim basic.conf

input {
  stdin {}
}
output {
  stdout {}
}

Step 8) start the service and check the journalctl logs
$ sudo service logstash start
$ sudo journalctl -u logstash -f

Sep 18 22:38:57 ip-10-3-1-204 systemd[1]: Started logstash.
Sep 18 22:38:57 ip-10-3-1-204 logstash[2716]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Sep 18 22:39:11 ip-10-3-1-204 logstash[2716]: Thread.exclusive is deprecated, use Thread::Mutex
Sep 18 22:39:15 ip-10-3-1-204 logstash[2716]: Sending Logstash logs to /var/log/logstash which is now configured via log4j2.properties
Sep 18 22:39:16 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:16,775][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.3.2"}
Sep 18 22:39:17 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:17,978][INFO ][org.reflections.Reflections] Reflections took 43 ms to scan 1 urls, producing 19 keys and 39 values
Sep 18 22:39:18 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:18,574][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge] A gauge metric of an unknown type (org.jruby.RubyArray) has been create for key: cluster_uuids. This may result in invalid serialization.  It is recommended to log an issue to the responsible developer/development team.
Sep 18 22:39:18 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:18,581][INFO ][logstash.javapipeline    ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>2, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>250, :thread=>"#<Thread:0x2aa8c99a run>"}
Sep 18 22:39:18 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:18,666][INFO ][logstash.javapipeline    ] Pipeline started {"pipeline.id"=>"main"}
Sep 18 22:39:18 ip-10-3-1-204 logstash[2716]: The stdin plugin is now waiting for input:
Sep 18 22:39:18 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:18,784][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
Sep 18 22:39:19 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:19,192][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
Sep 18 22:39:20 ip-10-3-1-204 logstash[2716]: [2019-09-18T22:39:20,430][INFO ][logstash.runner          ] Logstash shut down.
Sep 18 22:39:20 ip-10-3-1-204 systemd[1]: logstash.service: Service hold-off time over, scheduling restart.
Sep 18 22:39:20 ip-10-3-1-204 systemd[1]: logstash.service: Scheduled restart job, restart counter is at 1.
Sep 18 22:39:20 ip-10-3-1-204 systemd[1]: Stopped logstash.
Sep 18 22:39:20 ip-10-3-1-204 systemd[1]: Started logstash.
Sep 18 22:39:20 ip-10-3-1-204 logstash[2794]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Sep 18 22:39:35 ip-10-3-1-204 logstash[2794]: Thread.exclusive is deprecated, use Thread::Mutex
Sep 18 22:39:38 ip-10-3-1-204 logstash[2794]: Sending Logstash logs to /var/log/logstash which is now configured via log4j2.properties
Sep 18 22:39:39 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:39,961][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.3.2"}
Sep 18 22:39:41 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:41,183][INFO ][org.reflections.Reflections] Reflections took 40 ms to scan 1 urls, producing 19 keys and 39 values
Sep 18 22:39:41 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:41,810][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge] A gauge metric of an unknown type (org.jruby.RubyArray) has been create for key: cluster_uuids. This may result in invalid serialization.  It is recommended to log an issue to the responsible developer/development team.
Sep 18 22:39:41 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:41,814][INFO ][logstash.javapipeline    ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>2, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>250, :thread=>"#<Thread:0x4de38908 run>"}
Sep 18 22:39:41 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:41,893][INFO ][logstash.javapipeline    ] Pipeline started {"pipeline.id"=>"main"}
Sep 18 22:39:41 ip-10-3-1-204 logstash[2794]: The stdin plugin is now waiting for input:
Sep 18 22:39:42 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:42,038][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
Sep 18 22:39:42 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:42,434][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
Sep 18 22:39:43 ip-10-3-1-204 logstash[2794]: [2019-09-18T22:39:43,673][INFO ][logstash.runner          ] Logstash shut down.
Sep 18 22:39:43 ip-10-3-1-204 systemd[1]: logstash.service: Service hold-off time over, scheduling restart.
Sep 18 22:39:43 ip-10-3-1-204 systemd[1]: logstash.service: Scheduled restart job, restart counter is at 2.
Sep 18 22:39:43 ip-10-3-1-204 systemd[1]: Stopped logstash.

and the endless loop of restarts goes on and on, where am I missing a configuration to just get logstash up and listening so I can go test file beats?

I have also experimented with Java 8 and experienced the same issues

it looks like I needed to add an actual input other than stdin

I changed my default.conf file to the following and it stopped crashing

input {
  beats {
    port => 5044
  }
}
output {
  stdout {}
}

Well, I would not say it is "crashing" :slight_smile: I would expect stdin for a UNIX service to be connected to /dev/null. It is quite deliberate that when the stdin input reaches EOF then it causes logstash to exit (since it knows it will not get any further input). That will happen immediately for a service configured to use a stdin input. Many service managers will automatically restart a service that exits.

The combination means that the logstash service with that input will sit in a loop, exiting and restarting.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.