Skip to content

feat: Added possibility to detect local config file changes and reload#8529

Closed
vlastahajek wants to merge 1 commit intoinfluxdata:masterfrom
bonitoo-io:vh-watch-config-changes
Closed

feat: Added possibility to detect local config file changes and reload#8529
vlastahajek wants to merge 1 commit intoinfluxdata:masterfrom
bonitoo-io:vh-watch-config-changes

Conversation

@vlastahajek
Copy link
Copy Markdown
Contributor

@vlastahajek vlastahajek commented Dec 8, 2020

Closes #7187

There are situations (e.g. Kubernetes environment, Windows service) when restarting Telegraf due to config changes is cumbersome, and sending SIGHUP signal to achieve that is difficult.

Telegraf watching its config for changes will make this easy.

This PR adds watching for a single local config file only, not config dir or URL .

Watching is made using the infuxdata/tail lib and it is possible to be enabled via cmd option watch-config with two possible values:

  • inotify - uses fsnotify from tail
  • poll - uses polling from tail

However, polling from tail needs a fix (influxdata/tail#9) and until the tail is fixed, it is redirected to the fork with a simple fix.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@vlastahajek vlastahajek force-pushed the vh-watch-config-changes branch from fbb0739 to 45ddfcc Compare December 10, 2020 15:39
@vlastahajek vlastahajek changed the title feat: Added possibility to detect config changes and reload feat: Added possibility to detect local config file changes and reload Dec 10, 2020
@helenosheaa helenosheaa added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Feb 4, 2021
@ssoroka
Copy link
Copy Markdown
Contributor

ssoroka commented Apr 30, 2021

Note that you can already do this with --config-directory, as watching for file changes and reloading configuration is the default behavior for that.

@ssoroka ssoroka closed this Apr 30, 2021
sspaink added a commit that referenced this pull request Jul 8, 2021
Excluding windows specific changes
reimda pushed a commit that referenced this pull request Jul 28, 2021
@sjwang90
Copy link
Copy Markdown
Contributor

@vlastahajek do you know how this could be implemented for URL-based configs? This would be really helpful for our cloud customers and address use cases like this: #8730

@vlastahajek
Copy link
Copy Markdown
Contributor Author

@sjwang90, this shouldn't be hard.
As there is not guarantee that server holding the remote config supports HEAD (e.g. InfluxDB server doesn't) and also there is not guarantee that server will return info about the resource state, e.g. ETag header or Date-Modified header, easiest solution could be to store hash (MD5) of the current config and periodically (there should be parametrized time interval) download copy of the remote config, compute hash and compare. If changed, restart.

The question is, what should be default time interval for check to not bother server much? 1 minute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegraf watch and restart with new configuration file

4 participants