Logstash doesn't seem to recive file via TCP from nodejs


#1

Hi everyone!
I try to sent some files from node js app to logstash input tcp.
What the node file do? it fetches a minified json, and try to send it.
Even though the connections seems to be establishited and no errors occur, logstash dosn't output anything.

This is logstash conf file:

input {
tcp{
mode => "server"
port => 9563
codec => json
}
}
filter{}
output {
stdout{codec => rubydebug}
}

This is the node file:

const net = require('net')
fs = require('fs')
childPro = require('child_process')
addrhost = "some_ip"
addrport = 9563
var message

console.log(`starting client.js`);

var sendDataPromise = new Promise((resolve, reject) => {
    fs.readFile('./results', "utf8", (err, data) => {
        if (err) throw err;
        console.log("no errors found");
        this.message = data
        resolve('file read and saved localy')
    })

});
sendDataPromise.then((succMsg) => {
    console.log(succMsg);
    var conn = net.createConnection({ host: addrhost, port: addrport }, () => {
            console.log(`connected to ${addrhost} in ${addrport}`);
            console.log(`sending ${this.message}`);
            conn.write(JSON.stringify(this.message))
            process.exit(2)

        })
        .on('error', (err) => {
            console.error(err);
            process.exit(1)
        })
})

and finally, this is the logstash output:

[root@qa8 bin]# ./logstash -f /etc/logstash/conf.d/try_config.conf
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console

and it stays like this.
My system is CentOS 7, and the file size is in the single digit kbs.

Why dosn't logstash show anything?
Thanks!


(system) #2

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