Unable to get batch command to run in logstash output exec


(Michael Golubov) #1

I have a batch file in .../logstash/bin that looks like this:
copy c:\LogsIndexService\BackupXX\IndexInitializer.log c:\LogsIndexService

I am trying to run it from a pipeline output section as follows
output
{
exec {
command => "InitializeCopy.bat"
interval => 0
}

stdout {codec => rubydebug}

}

The file is not being copied - what am I doing wrong?


#2

What do you see in the logstash logs?


(Michael Golubov) #3

I simplified the pipeline to the following:
input
{
beats
{
port=>5043

        }

		jdbc {
                jdbc_driver_library => "C:\Users\mgolubov\elk\6.6.0\logstash-6.6.0\JDBC\mssql-jdbc-7.0.0.jre8.jar"
                jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
                jdbc_connection_string => "jdbc:sqlserver://gbwllslo015.gbl.ad.hedani.net:1433;dataBase=Reference;"
                jdbc_user=> "Toolbox"
                jdbc_password =>"Toolbox"
                jdbc_validate_connection=> "false"
				
                statement => "
								SELECT [ID]
								,[TimeZone]
								,[AdjustedHour]
								,[AdjustedMinute]
								FROM [Reference].[dbo].[tblTimeZones]					
							"
				type => "JobSchedule"
                schedule=> "*/30 * * * * *"         
                tags=> "JobSchedule"              
            }
} 

filter
{

}

output
{
exec {
command => "C:\Users\mgolubov\elk\6.6.0\logstash-6.6.0\bin\InitializeCopy.bat"
interval => 0
}

   stdout {codec => rubydebug}

}

When I tried to bring up logstash, I got this in logstash-plain.log:
[2019-04-15T15:36:35,619][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"6.6.0"}
[2019-04-15T15:36:40,770][ERROR][logstash.plugins.registry] Tried to load a plugin's code, but failed. {:exception=>#<LoadError: no such file to load -- logstash/outputs/exec>, :path=>"logstash/outputs/exec", :type=>"output", :name=>"exec"}
[2019-04-15T15:36:40,790][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:batchfile_Test, :exception=>"LogStash::PluginLoadingError", :message=>"Couldn't find any output plugin named 'exec'. Are you sure this is correct? Trying to load the exec output plugin resulted in this error: no such file to load -- logstash/outputs/exec", :backtrace=>["C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/plugins/registry.rb:211:in lookup_pipeline_plugin'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/plugin.rb:137:inlookup'", "org/logstash/plugins/PluginFactoryExt.java:222:in plugin'", "org/logstash/plugins/PluginFactoryExt.java:181:inplugin'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:71:in plugin'", "(eval):17:in'", "org/jruby/RubyKernel.java:994:in eval'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:49:ininitialize'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:90:in initialize'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/pipeline_action/create.rb:42:inblock in execute'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:92:in block in exclusive'", "org/jruby/ext/thread/Mutex.java:148:insynchronize'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:92:in exclusive'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/pipeline_action/create.rb:38:inexecute'", "C:/Users/mgolubov/elk/6.6.0/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:317:in `block in converge_state'"]}
[2019-04-15T15:36:41,110][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}

when I tried to install the plug-in, I got the following:


#4

I believe that error from the install is because you are using an old version of java. 51.0 is Java 7, so you need to use 7 or 8.


(Michael Golubov) #5

OutputPluginIssue2Java


(Michael Golubov) #6

As you can see above, the installed version of Java is 1.8.0_151. Do I need to upgrade this version and if so, what version will be safe as I have had elasticsearch initialization problems with versions greater than 151.


#7

I cannot imagine why Java 8 would fail to support 51.0.