How do I debug Telegraf? [closed]
Asked Answered
F

2

15

I'm trying to get Telegraf to work with InfluxDB and I've just hit a wall. I've added the following block to my Telegraf configuration file:

[[inputs.win_perf_counters.object]]
  # Process metrics, in this case for IIS only
  ObjectName = "Process"
  Instances = ["W3SVC"]
  Counters = ["% Processor Time","Handle Count","Private Bytes","Thread Count","Virtual Bytes","Working Set"]
  Measurement = "win_proc"

However, when I search my DB, I never see that measurement. I know that process is running, so it should be outputting something. The problem is that even though I have logging turned on, there's no logfile. There's also nothing in the event viewer. Short of downloading the source code and running the program in a local debugger, I have no idea how to proceed. Does anyone have any ideas?

Franzoni answered 1/6, 2020 at 17:19 Comment(0)
A
13
[agent]
  ## Default data collection interval for all inputs
  interval = "10s"
  ## Log at debug level.
  debug = true
  ## Log only error level messages.
  quiet = false

  ## Log target controls the destination for logs and can be one of "file",
  ## "stderr" or, on Windows, "eventlog".  When set to "file", the output file
  ## is determined by the "logfile" setting.
  # logtarget = "file"

  ## Name of the file to be logged to when using the "file" logtarget.  If set to
  ## the empty string then logs are written to stderr.
  # logfile = ""

You can specify debug = true in the agent config to print the debug logs. If you don't specify any log file, the logs will be printed on terminal.
Asper answered 3/6, 2020 at 11:46 Comment(1)
Turns out that I had the wrong format for the logfile string. I now have it logging, but the log is useless. There's still no error or explanation as to why it's not writing the win_proc measurement to the db. It's just line after line of "sent X measurement in y ms"Franzoni
S
12

You have probably solved it by now, but for further reference. You could add a file output.

[[outputs.file]]
  files = ["stdout"]

In your telegraf.conf and then watch the console (stdout) for output.

Sulphurize answered 3/7, 2022 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.