Use script output in Filebeat

I'm trying to use the output of a script as a field in my Filebeat. The command is:

kafkadev3-k1:~/kafka_2.10-0.10.2.0$ echo $(clustername)
kafkadev3

In which 'clustername' is an alias for a certain script. I want to use the output of this script("kafkadev3") as a field in my Filebeat, the config may look like this:

fields:
      clustername: 'echo $(clustername)'

And the filebeat output should be like:

{
    ...
    "clustername" => "kafkadev3",
    ...
    },

Is there a way I can do this? Or any suggestions?

Hi @Naruhodou and welcome! :slight_smile:

We currently don't support to run arbitrary commands in Beats, and in general we try to avoid running commands at all. An option you have is to pass this cluster name value as an environment variable. Environment variables can be used in Beats configuration files.

Yeah. That's the workaround I use right now. I use a script to export the value as an environment variable and then start Filebeat. Thanks for the help!

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