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

feat(config): Allow reloading on URL config change #15388

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

powersj
Copy link
Contributor

@powersj powersj commented May 21, 2024

Summary

This introduces a new config-url-watch-interval option, which when set will, at each interval, check the Last-Modified header of the file to determine if telegraf should reload.

If the header is not available then the watcher is disabled for the file.

Checklist

  • No AI generated code was used in this PR

Related issues

fixes: #8730

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label May 21, 2024
@powersj powersj self-assigned this May 22, 2024
This introduces a new config-url-watch-interval option, which when set
will, at each interval, check the Last-Modified header of the file to
determine if telegraf should reload.

If the header is not available then the watcher is disabled for the
file.

fixes: influxdata#8730
@powersj powersj marked this pull request as ready for review May 22, 2024 16:38
@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label May 22, 2024
@powersj powersj assigned srebhan and DStrand1 and unassigned powersj May 22, 2024
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I've once concern about removing the warning if we cannot watch a file...

Comment on lines 152 to 153
} else {
log.Printf("W! Cannot watch config %s: %s", fConfig, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this warning for local files? I'm not sure if there is a sensible case where you can read the file but not stat it, but if there is, I would like to inform the user that we are actually not watching a file he expects us to watch...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I've added a check, let me know if that is what you had in mind.

@powersj powersj requested a review from srebhan May 24, 2024 15:06
@telegraf-tiger
Copy link
Contributor

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks @powersj!

@srebhan srebhan removed their assignment May 27, 2024
@DStrand1 DStrand1 merged commit 0e636b7 into influxdata:master Jun 3, 2024
27 checks passed
@github-actions github-actions bot added this to the v1.31.0 milestone Jun 3, 2024
@Joris97
Copy link

Joris97 commented Jun 12, 2024

How does this new function work? Putting "configURLWatchInterval: 1m " under agent or is this already explained somewhere?

@powersj
Copy link
Contributor Author

powersj commented Jun 12, 2024

How does this new function work? Putting "configURLWatchInterval: 1m " under agent or is this already explained somewhere?

It's a CLI option --config-url-watch-interval. telegraf --help should list it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Telegraf reloads URL-based/remote config on a specified interval
4 participants