telegraf: Can't start Telegraf Service Inputs.exec Linux

Relevant telegraf.conf:


[[inputs.exec]]
  ## Commands array
  commands = ["telegraf --version | awk '{print($2)}' | awk -F '.' '{print($1"."$2)}'"]
  ## Timeout for each command to complete.
  timeout = "5s"

  ## measurement name suffix (for separating different commands)
  name_suffix = "_mycollector"

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "influx"

System info:

Steps to reproduce:

  1. Place command in the command block

Expected behavior:

Display Telegraf version number

Actual behavior:

Process fails to start

Additional info:

Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.

Command executes sucessfully in the terminal: telegraf --version | awk ‘{print($2)}’ | awk -F ‘.’ ‘{print($1"."$2)}’ 1.11

This is probably just formatting but I’m not sure what I’m doing wrong.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

That did it!

Adding the end result.

[[inputs.exec]]
  ## Commands array
  commands = ["sh -c \"telegraf --version | awk '{print($2)}' | awk -F '.' '{print($1\\\".\\\"$2)}'\""]
  ## Timeout for each command to complete.
  ## Timeout for each command to complete.
  timeout = "5s"


  ## measurement name suffix (for separating different commands)
  #name_suffix = "_mycollector"
  name_override = "TelegrafVersion"

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "value"
  data_type = "float"

Thanks for your help friend!