Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(plugins): Allow to override log-level per plugin #15677

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

srebhan
Copy link
Member

@srebhan srebhan commented Jul 29, 2024

Summary

This PR allows to override the Telegraf-wide log-level on a per plugin basis allowing to e.g. debug a certain plugin without being spammed by debug messages of other plugins.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #6584

@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 Jul 29, 2024
@srebhan srebhan 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 Jul 29, 2024
@DStrand1 DStrand1 removed their assignment Jul 29, 2024
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

This does not appear to work as I thought it would. For example, with this config I would expect to see debug messages from sarama:

[agent]
  debug = false
  omit_hostname = true

[[inputs.kafka_consumer]]
  log_level = "debug"
  brokers = ["localhost:9092"]
  topics = ["telegraf"]

It is not until I set the agent level debug to true do those messages appear.

Another example, where I would expect to see only info messages, but I see debug message about what server is in use for the test:

[agent]
  omit_hostname = true
  debug = true

[[inputs.internet_speed]]
  log_level = "info"
  interval = "1m"

[[outputs.file]]

@srebhan
Copy link
Member Author

srebhan commented Jul 29, 2024

@powersj thanks for the thorough testing! It seems like during git rebase some of the model-config settings were lost and only the output model got the actually configured log-level. Pushed an update...

@srebhan srebhan requested a review from powersj July 29, 2024 20:53
@telegraf-tiger
Copy link
Contributor

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Much better!

We may need to do a follow up with the sarama logging for example. It looks to only respect the agent level debug value and I think that is how the logic is set up right now, but this gets us plugin specific log levels!

@powersj powersj merged commit f9f029e into influxdata:master Jul 30, 2024
27 checks passed
@github-actions github-actions bot added this to the v1.32.0 milestone Jul 30, 2024
@srebhan
Copy link
Member Author

srebhan commented Jul 31, 2024

@powersj solved the sarama issues in the course of #15695...

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.

Enable debug logging on a per-plugin basis
3 participants