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

Output plugin "file" does not close the file after flush. #5581

Closed
Nyyr1 opened this issue Mar 13, 2019 · 4 comments
Closed

Output plugin "file" does not close the file after flush. #5581

Nyyr1 opened this issue Mar 13, 2019 · 4 comments
Labels
feature request Requests for new plugin and for new features to existing plugins

Comments

@Nyyr1
Copy link

Nyyr1 commented Mar 13, 2019

Relevant telegraf.conf:

[global_tags]
[agent]
  interval = "60s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "60s"
  flush_jitter = "0s"
  precision = ""
  debug = false
  quiet = false
  logfile = ""
  hostname = ""
  omit_hostname = false
[[outputs.file]]
  files = ["/tmp/metrics.out"]
  data_format = "json"
[[inputs.statsd]]
  protocol = "udp"
  max_tcp_connections = 250
  tcp_keep_alive = false
  service_address = ":8125"
  delete_gauges = true
  delete_counters = true
  delete_sets = true
  delete_timings = true
  percentiles = [90]
  metric_separator = "."
  parse_data_dog_tags = false
  allowed_pending_messages = 10000
  percentile_limit = 1000

System info:

telegraf-1.10.0-1.x86_64
NAME="Amazon Linux AMI"
VERSION="2015.09"
Linux 66185ca101a9 4.1.17-22.30.amzn1.x86_64 #1 SMP Fri Feb 5 23:44:22 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce:

  1. echo "statsd.test.metric:a|s" | ncat -u localhost 8125
  2. wait for "flush_interval"
  3. delete the file
  4. wait for "flush_interval"
  5. no new file appears

If you just truncate the file, the new metric does not appear till the file grows to its previous size (filled with zeros).

Expected behavior:

If the file is deleted then at the end of the flush_interval new one appears with the new metric.

Actual behavior:

See "Steps to reproduce".

@glinton
Copy link
Contributor

glinton commented Mar 13, 2019

As far as I know, there isn't an efficient way to detect that a file has been deleted while writing. Opening and closing the file on every call to write would be terribly slow, and while stating the file before write would work, it would also have poor performance.
If there is a solution I have overlooked, please share. I'm not sure the use case on this, but there is a pr to add file rotation to the file output.

@Nyyr1
Copy link
Author

Nyyr1 commented Mar 14, 2019

@glinton
Copy link
Contributor

glinton commented Mar 14, 2019

While my experience has shown that fsnotify is not without it's issues/caveats/limitations, I suppose it could work fine in this capacity as we wouldn't be watching a directory, but individually listed files.

@glinton glinton added the feature request Requests for new plugin and for new features to existing plugins label Mar 14, 2019
@danielnelson
Copy link
Contributor

You can signal Telegraf to reopen the file with a SIGHUP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

No branches or pull requests

3 participants