Hello World doesn't output to Logstash

I have a Logstash conf file configured as such:

    input {
        exec {
            command => "/etc/logstash/scripts/do_something.py"
            interval => 60
        }
    }

    output {
        stdout {}
    }

The executed Python script is as follows:

    print('Hello world!')

That's it. As bog-standard and as straightforward as this. And now, here's what actually lands into the stdout console when I monitor Logstash's logging:

    Apr  7 14:05:34 myhostname logstash: {
    Apr  7 14:05:34 myhostname logstash: "host" => "myhostname.mydomain.com",
    Apr  7 14:05:34 myhostname logstash: "command" => "/etc/logstash/scripts/do_something.py",
    Apr  7 14:05:34 myhostname logstash: "@timestamp" => 2020-04-07T18:05:34.781Z,
    Apr  7 14:05:34 myhostname logstash: "message" => "",
    Apr  7 14:05:34 myhostname logstash: "@version" => "1"
    Apr  7 14:05:34 myhostname logstash: }

For whatever reason I don't understand, the execution completes successfully, but the words "Hello World!" aren't present at all. Yet, if I run the Python script standalone, "Hello World!" does output to the console as normal.

Meanwhile, I have several other Logstash pipelines and Python scripts that are much more elaborate and output what shows up in stdout to various destinations, and they work 100%.

Obviously I must be doing something dead wrong in what turns out to be no more than the most basic of tests. I must've been banging myself against this for far too long, because I can't for the life of me figure out what's going on. I had begun with a slightly modified copy of another pipeline/script to test some error handling, and in trying to figure out the root cause of why my test wouldn't output anything, stripped it down until I was reduced to... this. A plain simple Hello World that should be foolproof, yet, go figure... isn't.

Any insight would be greatly appreciated.

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