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

Error when table `inputs.http_response.headers' is in conflict with normal table #5635

Closed
Gelob opened this issue Mar 26, 2019 · 5 comments
Closed
Labels
area/configuration help wanted Request for community participation, code, contribution size/m 2-4 day effort

Comments

@Gelob
Copy link

Gelob commented Mar 26, 2019

Relevant telegraf.conf:

System info:

telegraf v1.10.1-1
CentOS Linux release 7.6.1810 (Core)

Steps to reproduce:

Since inputs.http_response doesn't support multiple addresses in an array like inputs.http (#2294) (this really should be fixed) you have to setup multiple inputs. However when setting up multiple inputs while also using inputs.http_response.headers I get an error about a conflict from the previous input.

I read #4098 but that deals with inputs.http and inputs.http_response documentation already suggest not using non-inline table syntax. Even using inline table syntax the issue still occurs. I'm not sure if #5513 would fix this either

[[inputs.http_response]]
  address = "https://10.1.1.251/restconf/data/Cisco-IOS-XE-native:native/hostname"
  method = "GET"
  response_string_match = "Cisco-IOS-XE-native:hostname.: \"CSR1000v\""
  insecure_skip_verify = true
  [inputs.http_response.headers]
    Content-Type = "application/yang-data+json"
    Accept = "application/yang-data+json"
    Authorization = "Basic passwordremoved"

[[inputs.http_response]]
  address = "https://10.1.1.252/restconf/data/Cisco-IOS-XE-native:native/hostname"
  method = "GET"
  response_string_match = "Cisco-IOS-XE-native:hostname.: \"CSR1000v\""
  insecure_skip_verify = true`
  [inputs.http_response.headers]
    Content-Type = "application/yang-data+json"
    Accept = "application/yang-data+json"
    Authorization = "Basic passwordremoved"

Expected behavior:

Telegraf should run without errors and process both inputs.http_response plugins and their headers.

When run with just 1 input plugin everything is successful

[root@Smyserver~]# telegraf --config /etc/telegraf/telegraf.conf --input-filter http_response --test
2019-03-26T13:56:39Z I! Starting Telegraf 1.10.1
> http_response,method=GET,result=success,server=https://10.1.1.251/restconf/data/Cisco-IOS-XE-native:native/hostname,status_code=200 http_response_code=200i,response_string_match=1i,response_time=0.134175048,result_code=0i,result_type="success" 1553608600000000000

Actual behavior:

Error occurs:

[root@myserver ~]# telegraf --config /etc/telegraf/telegraf.conf --input-filter http_response --test
2019-03-26T13:47:14Z I! Starting Telegraf 1.10.1
2019-03-26T13:47:14Z E! [telegraf] Error running agent: Error parsing /etc/telegraf/telegraf.conf, toml: line 387: table `inputs.http_response.headers' is in conflict with normal table in line 377

@danielnelson
Copy link
Contributor

Your configuration works for me, though there was a stray backtick that needs removed in the second plugin. Here is a complete working config you can run:

[[inputs.http_response]]
  address = "https://10.1.1.251/restconf/data/Cisco-IOS-XE-native:native/hostname"
  method = "GET"
  response_string_match = "Cisco-IOS-XE-native:hostname.: \"CSR1000v\""
  insecure_skip_verify = true
  [inputs.http_response.headers]
    Content-Type = "application/yang-data+json"
    Accept = "application/yang-data+json"
    Authorization = "Basic passwordremoved"

[[inputs.http_response]]
  address = "https://10.1.1.252/restconf/data/Cisco-IOS-XE-native:native/hostname"
  method = "GET"
  response_string_match = "Cisco-IOS-XE-native:hostname.: \"CSR1000v\""
  insecure_skip_verify = true
  [inputs.http_response.headers]
    Content-Type = "application/yang-data+json"
    Accept = "application/yang-data+json"
    Authorization = "Basic passwordremoved"

[[outputs.file]]
  files = ["stdout"]

@Gelob
Copy link
Author

Gelob commented Mar 26, 2019

@danielnelson the stray backtick was a typo here but not in my actual config. I put the above config into a new file and it worked, however I have more than this configuration in my full telegraf.conf. I also have an inputs.http plugin enabled and when I include that above this configuration I get the error. See below for full config.

[[inputs.http]]
  urls = [
    "https://10.1.1.251/restconf/data/Cisco-IOS-XE-native:native/hostname",
    "https://10.1.1.252/restconf/data/Cisco-IOS-XE-native:native/hostname"
  ]
   method = "GET"
   headers = {"Content-Type" = "application/yang-data+json","Accept" = "application/yang-data+json"}
   username = "username"
   password = "password"
   insecure_skip_verify = true
   name_override = "cisco_restconf"
   json_string_fields = ["Cisco-IOS-XE-native:hostname"]
   data_format = "json"
   [inputs.file.tags]
     tag1 = "hostname"

[[inputs.http_response]]
  address = "https://10.1.1.251/restconf/data/Cisco-IOS-XE-native:native/hostname"
  method = "GET"
  response_string_match = "Cisco-IOS-XE-native:hostname.: \"CSR1000v\""
  insecure_skip_verify = true
  [inputs.http_response.headers]
    Content-Type = "application/yang-data+json"
    Accept = "application/yang-data+json"
    Authorization = "Basic passwordremoved"

[[inputs.http_response]]
  address = "https://10.1.1.252/restconf/data/Cisco-IOS-XE-native:native/hostname"
  method = "GET"
  response_string_match = "Cisco-IOS-XE-native:hostname.: \"CSR1000v\""
  insecure_skip_verify = true
  [inputs.http_response.headers]
    Content-Type = "application/yang-data+json"
    Accept = "application/yang-data+json"
    Authorization = "Basic passwordremoved"

@danielnelson
Copy link
Contributor

Interesting, I didn't know it would conflict across table types. For the record the workaround is to use only non-inline tables throughout the config. Also I spotted an issue in the naming of the tag table, corrected below:

 [[inputs.http]]
   urls = [
     "https://10.1.1.251/restconf/data/Cisco-IOS-XE-native:native/hostname",
     "https://10.1.1.252/restconf/data/Cisco-IOS-XE-native:native/hostname"
   ]
    method = "GET"
-   headers = {"Content-Type" = "application/yang-data+json","Accept" = "application/yang-data+json"}
    username = "username"
    password = "password"
    insecure_skip_verify = true
    name_override = "cisco_restconf"
    json_string_fields = ["Cisco-IOS-XE-native:hostname"]
    data_format = "json"
+   [inputs.http.headers]
+     Content-Type = "application/yang-data+json"
+     Accept = "application/yang-data+json"
+   [inputs.http.tags]
+     tag1 = "hostname"

@glinton We should add a unit test for the mixed table case to #5513, if it fails then we should probably purge this style from the sample config for now.

@danielnelson danielnelson added area/configuration bug unexpected problem or unintended behavior and removed need more info labels Mar 26, 2019
@goller goller removed the bug unexpected problem or unintended behavior label Apr 1, 2019
@sandeep11823
Copy link

I am getting the answer i want to upload it in influx now

@powersj powersj added size/m 2-4 day effort help wanted Request for community participation, code, contribution labels Aug 16, 2022
@powersj
Copy link
Contributor

powersj commented Aug 16, 2023

Going through old issues and trying to reproduce this. I went as far back as telegraf v1.14.0 and found that the config in this comment with both inputs.http and 2x inputs.http_response works as expected.

Closing as fixed, but if someone comes across something similar please file a new issue using the latest telegraf, and provide a full config to reproduce.

Thanks!

@powersj powersj closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration help wanted Request for community participation, code, contribution size/m 2-4 day effort
Projects
None yet
Development

No branches or pull requests

5 participants