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]] error table `headers' is in conflict #4098

Closed
marcoc610 opened this issue May 3, 2018 · 2 comments · Fixed by #5513
Closed

[[inputs.http]] error table `headers' is in conflict #4098

marcoc610 opened this issue May 3, 2018 · 2 comments · Fixed by #5513
Labels
area/configuration bug unexpected problem or unintended behavior upstream bug or issues that rely on dependency fixes
Milestone

Comments

@marcoc610
Copy link

marcoc610 commented May 3, 2018

I need to define multiple instances of the inputs.http plugin.

This plugin seems not to allow "headers" in multiple instances.
A configuration like the one below produces an error in toml parsing:

toml: line 11: table headers' is in conflict with normal table in line 5`

Relevant telegraf.conf:

[[inputs.http]]
  urls = [
    "https://HOST1/api/"
  ]
  headers = {"Authorization" = "Basic YXBpdXNlcjphcGlwYXNzMTg="}

[[inputs.http]]
  urls = [
    "https://HOST2/api/"
  ]
  headers = {"Authorization" = "Basic YXBpdXNlcjphcGlwYXNzOA=="}

If I remove one of the headers lines, the configuration is accepted.
The behaviour does not change if:

  1. I change the header contents (different key/value pairs)
  2. I change the toml table format (from headers={...} to [headers] ...)
  3. I add or remove other lines to the plugin configuration (data_format, insecure_skip_verify, taginclude,...)

I know that this particular case can be addressed using the plugin syntax

username=
password=

but I need to define multiple instances because different systems require different headers.

System info:

Telegraf v1.6.1 (git: release-1.6 bf0ab27)
on
Ubuntu 16.04

Actual behavior:

$ telegraf --test --config-directory /etc/telegraf/telegraf.d

2018/05/03 13:17:58 I! Using config file: /etc/telegraf/telegraf.conf
2018/05/03 13:17:58 E! Error parsing /etc/telegraf/telegraf.d/aaa.conf, toml: line 11: table `headers' is in conflict with normal table in line 5
@danielnelson
Copy link
Contributor

This appears to be a bug in the toml parser we are using, which is an out of date fork of naoina/toml.

As a workaround you can use regular non-inline table syntax:

[[inputs.http]]
  [inputs.http.headers]
    Authorization = "Basic YXBpdXNlcjphcGlwYXNzMTg="

[[inputs.http]]
  [inputs.http.headers]
    Authorization = "Basic YXBpdXNlcjphcGlwYXNzOA=="

Make sure you put all tables at the end of the plugin config so nothing inadvertently becomes falls under it.

@danielnelson danielnelson added bug unexpected problem or unintended behavior area/configuration upstream bug or issues that rely on dependency fixes labels May 3, 2018
@marcoc610
Copy link
Author

Thank you @danielnelson !
It actually works with your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration bug unexpected problem or unintended behavior upstream bug or issues that rely on dependency fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants