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

inputs.http plugin does not respect token_file #14347

Closed
jyrkih opened this issue Nov 27, 2023 · 1 comment · Fixed by #14350
Closed

inputs.http plugin does not respect token_file #14347

jyrkih opened this issue Nov 27, 2023 · 1 comment · Fixed by #14350
Labels
bug unexpected problem or unintended behavior

Comments

@jyrkih
Copy link

jyrkih commented Nov 27, 2023

Relevant telegraf.conf

[[inputs.http]]

  ## One or more URLs from which to read formatted metrics.
  urls = [
    "https://xxxxxx",
  ]
  token_file = "/tmp/bearer_token_file"

Logs from Telegraf

docker-telegraf-1  | 2023-11-27T14:00:00Z E! [inputs.http] Error in plugin: [url=https://xxxxxx]: open : no such file or directory

System info

Telegraf 1.28.5

Docker

FROM telegraf:latest

Steps to reproduce

  1. define custom bearer token using token_file

...

Expected behavior

http input plugin should open the file containing the bearer token

Actual behavior

error which says that file cannot be opened.

Additional info

I think it's part in http.go:

} else if h.TokenFile != "" {
token, err := os.ReadFile(h.BearerToken)

I.e. it tries to open file given in the deprecated bearer_token

@jyrkih jyrkih added the bug unexpected problem or unintended behavior label Nov 27, 2023
powersj added a commit to powersj/telegraf that referenced this issue Nov 27, 2023
@powersj
Copy link
Contributor

powersj commented Nov 27, 2023

Thank you for taking the time to file and issue and even find the root cause. I have put up #14350 with a fix.

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