Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If file output cannot write to stdout it does not write to other files #4018

Closed
NomNomSu opened this issue Apr 13, 2018 · 3 comments · Fixed by #4055
Closed

If file output cannot write to stdout it does not write to other files #4018

NomNomSu opened this issue Apr 13, 2018 · 3 comments · Fixed by #4055
Labels
bug unexpected problem or unintended behavior

Comments

@NomNomSu
Copy link

Bug report

Telegraf is not saving from [[inputs.sqlserver]] to [[outputs.file]] when running it as Windows service but it works correctly when running it from command line. Service was ran on administrator account so it had administrator priviledges.

Relevant telegraf.conf:

[global_tags]
  # dc = "us-east-1" # will tag all metrics with dc=us-east-1
  # rack = "1a"

# Configuration for telegraf agent
[agent]
  interval = "5s"
  round_interval = true
  metric_buffer_limit = 1000
  flush_buffer_when_full = true
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  debug = true
  quiet = false
  logfile = "C:/Program Files/Telegraf/telegraf.log"
  hostname = ""


###############################################################################
#                                  OUTPUTS                                    #
###############################################################################

[[outputs.file]]
  ## Files to write to, "stdout" is a specially handled file.
  files = ["stdout", "C:/temp/sql/sqlperf.out"]
  data_format = "json"
  json_timestamp_units = "1ns"


###############################################################################
#                                  INPUTS                                     #
###############################################################################

[[inputs.sqlserver]]
  servers = [
    "Server=localhost\\servername;Port=1433;User Id=telegraf;Password=***********;app name=telegraf;log=1;",
  ]

System info:

Telegraf 1.5.3
Telegraf v1.7.0~0a02363c

Windows Server 2012 R2
Telegraf Running as service with --config parameter

Steps to reproduce:

  1. Create config with [[inputs.sqlserver]] and [[outputs.file]]
  2. Create windows service in powershell with command: $path/telegraf.exe --service install --config $path\telegraf.conf
  3. Run service

Expected behavior:

output file is created and data is written to file

Actual behavior:

output file is created but file has always 0 bytes

Additional info:

when the same config is run from command line using $path/telegraf.exe --config $path/telegraf.conf file is created and data is written correctly.

With debug on, telegraf log when running from command line:

2018-04-13T08:56:18Z D! Attempting connection to output: file
2018-04-13T08:56:18Z D! Successfully connected to output: file
2018-04-13T08:56:18Z I! Starting Telegraf v1.7.0~0a02363c
2018-04-13T08:56:18Z I! Loaded outputs: file
2018-04-13T08:56:18Z I! Loaded inputs: inputs.sqlserver
2018-04-13T08:56:18Z I! Tags enabled: host=****
2018-04-13T08:56:18Z I! Agent Config: Interval:5s, Quiet:false, Hostname:"****", Flush Interval:10s
2018-04-13T08:56:30Z D! Output [file] buffer fullness: 627 / 1000 metrics.
2018-04-13T08:56:31Z D! Output [file] wrote batch of 627 metrics in 1.0210848s

With debug on, telegraf log when running as service:

2018-04-13T08:52:13Z D! Attempting connection to output: file
2018-04-13T08:52:13Z D! Successfully connected to output: file
2018-04-13T08:52:13Z I! Starting Telegraf v1.7.0~0a02363c
2018-04-13T08:52:13Z I! Loaded outputs: file
2018-04-13T08:52:13Z I! Loaded inputs: inputs.sqlserver
2018-04-13T08:52:13Z I! Tags enabled: host=*****
2018-04-13T08:52:13Z I! Agent Config: Interval:5s, Quiet:false, Hostname:"*****", Flush Interval:10s

@danielnelson
Copy link
Contributor

Does it help if you remove the "stdout" file from the file output?

@NomNomSu
Copy link
Author

Yes it does, thanks a lot!

@danielnelson
Copy link
Contributor

To fix this we should warn if stdout is not available, but not stop output to all files.

@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Apr 17, 2018
@danielnelson danielnelson changed the title Telegraf does not save sql data to file when running as Windows service If file output cannot write to stdout it does not write to other files Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants